I have the following Model
public class FooContainer
{
public int ID { get; set; }
public string Name { get; set; }
public IList<Foo> Foos { get; set; }
}
public class Foo
{
public string Name {get; set; }
public string Description {get; set;}
}
Example Controller
public class FooController : Controller
{
public ActionResult Index(){
return View(new FooContainer());
}
[HttpPost]
public ActionResult Index(FooContainer model){
//Do stuff with the model
}
}
I want to create a view which enables the user to CRUD Foos.
Existing Research
I have read the following:
http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx
http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx
along with the following SO articles
MVC4 Allowing Users to Edit List Items
MVC4 bind model to ICollection or List in partial
So i know how to pass an IEnumerable<> back and forth, the problem is that i want to pass some container, with other attributes including an IEnumerable<>
Requirement
I want to be able to bind to this complex model so that it is passed completely and in its entirety to the controller. Assume that the controller does nothing but render the view and receive the FooController model on post. Additionally i would like any relevant articles or references to View syntax required to enable this.
Thanks in advance