Click here to Skip to main content
15,446,232 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm working on ASP.net MVC4 web app. There are Product, ProductProperty, ProductCategory models:

XML
public class Product
{
    public int Id { get;set;}
    public string Name {get;set;}
    public byte ProductCategoryId { get; set;}
    public virtual ProductCategory ProductCategory {get; set;}
    public List<PropertyValue> PropertyValues {get;set;}
}

public class ProductProperty
{
    public int Id { get; set; }
    public string Name{ get;set;}
    public virtual List<PropertyValue> PropertyValues{get;set;}
    public virtual List<ProductCategory> ProductCategories{get;set;}
}

public class ProductCategory
{
    public byte Id {get;set;}
    public string Name { get; set;}
    public List<Product> Products;
    public virtual List<ProductProperty> ProductProperties {get; set;}
}



Each product reffers to category and each product property applies to one or more categories, Product model has List of property values which depends on category.

I do not know how to implement Create and Edit views and controller actions for products.

When product send to Create view its category is not selected, but after it selected there should be post back or ajax which would create DropDownLists with PropertyValues of ProductProperties reffered to selected Category. Then after final post Product object with List of PropertyValues should be saved in DB.

That is really confusing, please advice if there simple and elegant solution.

Thank you!
Posted

1 solution

I'd show a drop list of available categories and properties, and a pop up to add new items to the list. I expect this would require writing all of the code yourself and not relying on the templated code that you can get auto generated by the IDE.

I'd also use entity framework ( by default ) and expect that EF would expose all the sub properties of each connected type, because of proper relationships in the database.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900