c# - How to define model property for master detail -
i have post model every post it's need define category , tag , , category or tag wanna reach of posts have category of tag. blog model
public class post { public guid id { get; set; } public string title { get; set; } public string body { get; set; } public string summary { get; set; } public datetime creationdate { get; set; } public string urlslug { get; set; } public category category { get; set; } public tag tag { get; set; } } and category:
public class category { public guid id { get; set; } public string name { get; set; } public string urlslug { get; set; } public string description { get; set; } public datetime creationdate { get; set; } public ilist<post> posts { get; set; } } and tag model:
public class tag { public guid id { get; set; } public string name { get; set; } public string urlslug { get; set; } public string description { get; set; } public datetime creationdate { get; set; } public ilist<post> posts { get; set; } } i want know i've done in designing model right or not ??
you dont need lists in model ( remove public ilist posts { get; set; }
first create 2 actions in controller takes tag id, , other`category id. inside actions posts , populate view ( detail view)
public actionresult postsbycategoryid(guid id) { list<post> posts = ///get them id return view(posts) ; //the view take list , displays posts }
Comments
Post a Comment