Virto Commerce Parent Customer Relationship Needed [closed] - c#

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I'm looking to create a parent customer that has child customers underneath it. So for example Home Depot as the parent and store #300 as the child.

Yes it is possible. You need to however identify what is different between the stores and what information you'd like to have available for each store.
1st thing you can do is to create a master catalog which will be managed by parent and then create a virtual catalog for a child. Then create two stores, one for parent and one for child (assigning appropriate catalogs for each). This will allow you to control which products are available in which store and also control taxonomy (categorization) for each store.
You can also control security for each store using organizational structure. For instance if it is a B2B solution, you can create organizational structure where parent organization is Home Depot while child organization is your store. Now all employees from child org will belong to that child org and can have limited set of permissions.
Another possibility is if you want to manage inventory differently for each store. In that case you will need to create fulfillment centers and assign them to a specific store. That way product can be made available in one store and not in the other.

Related

Advice needed on c#MVC/EF modelling strategies [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 days ago.
Improve this question
Context:
I am writing a web application using SQL server database, C# MVC API layer, Next (React) front end. The database is already created and populated and is in full Third Normal Form (3NF) and the base entity classes have been autogenerated from the database, so using a database-first modelling approach. This will seem like a bit of a rant, but I want to know if I am approacing this correctly because it feels like an awful lot of boiler plate code but this may just be because my project is not big enough to reap the benefits.
These aren't my tables but the relationship is the same; namely 1:many relationships with a primary key of ParentTable.id and foreign key of ChildTable.ParentTable_id
Consider a system with 4 tables: Store, Customer, Order, OrderLine. Each customer belongs to only one store and each order belongs to only 1 customer. The base models have their respective links (1 Parent => N Children) and Inverse Link (1 Child => 1 Parent). When you call the .../api/store it doesn't contain any customers by default. If you modify the controller
_context.Stores.Include("Customers").ToListAsync()
This throws an error when returning it as JSON because of the cyclic link so I need to create ViewModels for both the Customer (exluding the Stores model, but just keeping the storeID) and for the Store (including the collection of CustomerViewModel). This is fine while this is the only VM I need for customer or store but what if I also need a customer view model that includes the orders, or a viewmodel for the marketing team and a different one for the finance team. What options do I have? I am thinking either different model names within the same namespace
StoreCustomerViewModel
FinanceCustomerViewModel
MarketingCustomerViewModel
or using namespaces
using ...models.finance -> CustomerViewModel
using ...models.marketing -> CustomerViewModel
Or am I thinking about this the wrong way? If I need to combine models (e.g. where the main model contains a collection of other models - Customer.orders = List-OrdersViewModel) can these cut across namespaces and if so how and what are the caveats around that.
I'm not sure but once I stumbled upon a similar problem (Eager Loading).
Some advised to use [JsonIgnore] above the properties I don't want.
others advised to add UseLazyLoading() in my program.cs
But what really worked for me was creating DTOs and using AutoMapper.
So try out each option and see what works for your project.

User Controlls to Main Form C# [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am using Windows Forms .NET C# for this project
I am making a school project for a cafe ordering system. And the coffee aspect is a simple custom controller that allows users to pick out a size of the coffee, how many sugars and creams they want. My issue is that I then have to take that user control inputs and store them in the main form list and inside a ListBox as a display of an order.
Does anyone know how to store user control inputs into a main form List<>?
The best way is to create a class to store info about order, let's call it class "Order". Each order will be represented by instance of this class (you pass your control's values as parameters to the constructor). You can store orders in the List<Order>.
To add it to the ListBox, you must override ToString() method:
public override string ToString(){ return "onfo to show" }
This method will show info about order from your class in the way you like.
P.s. for more specific help provide sample code of what you have tried since now.

Issue regarding fetching data from DB using LINQ and .NET [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Actually I don't have the idea that whether I should use some technique in storing data so that I can fetch according to my requirement or just need to search a query returning data according to my requirement. I want to store some data that is linked with eachother some rough data is given below
Name Reference City
Mian Null GUj
Hamza Mian Khi
Adam Mian Lhr
Jamil Adam Lhr
Musa Jamil Khi
Subhan Musa ISL
I want the solution that when I enter some name its fetches data of that person and its all childs and sub childs.
Ex:
If I enter Adam acoording to above table info it should return Adam, Jamil, Musa, Subhan.
Well you must have a foreign key for the parent.
Here is an example
select * from person parent
left join person child on child.Parent_ID = parent.ID
where parent.Name like 'Adam'
I think this should work for you, you could also left join the sub children of the sub children.
Or you can write query that search recursive.
Please see this article for more info
recursive-select

Structure for shop (e-commerce) database [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I write my project and I will give to user to add his store to my system and then user will can to add shopItem to his store.
My question is:
Maybe already exist shop database for Category-Subcategory.
I mean - When user will add for example boots - he need choose
Category Clothes -> then choose Subcategory Shoes.
So i need database with all category-subcategory for MS SQL - or other database (maximum I will write script for transfer data to MS SQL)
Thank you.
Regards,
David.
You are talking about a hierarchical relationship. Typically you would have a Category database which has a primary key (say, CategoryID). If a subcategory can only belong to single category, then you would have another field in your Category table (maybe called ParentCategoryID). For root-level categories, this field would be NULL. For a subcategory, ParentCategoryID would contain the CategoryID of whatever category is the parent (pretty logical).
If a subcategory can exist under multiple categories, then you need a mapping table that contains the CategoryID and ParentCategory ID.
If you need a subcategory also to be allowed to be a root category, then your mapping table has to take this into account (maybe by allowing NULLs in the ParentCategoryID table)
MSDN has a tutorial on hierarchical data structures here: https://msdn.microsoft.com/en-us/library/bb677213.aspx

Is it a bad design to have a structure where one class contains list of another class and vice versa [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I was working on design of User Role Management system. In this system a user can have many roles and a role can have many users. It is one to many relationship in between both user and role. I was thinking of a design to establish this relationship as:
Class User
{
List<Role>
}
Class Role
{
List<User>
}
My question is, Is this a bad design.If yes what should be the recommended way to establish relationship.
Regards
I don't understand any previous accusations of a bad design. This is a typical design to map many-to-many relationships. In particular if you use Entity Framework, you get relationships like this all the time.
You can even have a self-reference, why not?
class Person
{
List<Person> Friends;
}
It is not that bad or uncommon to do this in the context of child and parent objects.
Class User
{
List<Role> Children;
}
Class Role
{
List<User> Parents;
}
This way you always know the linking from parents to childs.
An example would be the XMLNode Class in the .NET Framework.
It has ChildNodes and ParentNode properties.
Yes, I would consider this bad design because now you have two lists to maintain, assuming this even compiles with cross referencing.
You are much better to either create a joining object that something else holds a list of (A class that has both user and a role).
Or just pick the one that makes the most sense and then apply some querying on that when need to find all users with a specific role. I.E
myListOfUsers.Where(user => user.Roles.Contains(something));

Categories