I am seeking help to understand the documentation found here:
http://demos.telerik.com/aspnet-mvc/treelist/remote-data-binding
My questions are:
In the following snip it
public JsonResult Create([DataSourceRequest] DataSourceRequest request, EmployeeDirectoryModel employee)
{
if (ModelState.IsValid)
{
employeeDirectory.Insert(employee, ModelState);
}
return Json(new[] { employee }.ToTreeDataSourceResult(request, ModelState));
}
In this example the purpose is to create (insert) a new record. To do this this function calls the Insert method of the employeeDirectory method (which is presumable a method of the EmployeeDirectoryModel and it takes two parameters the employee (which was passed into this calling function, and the ModelState.
My question is, what does this Insert method do with the ModelState? It is passed in for a reason, so what is that reason?
The employee parameter will contain the data to be written to the database, except the primary key, does the Insert method load the primary key value into the model so that when it gets returned back (last line of snip it), there will be a fully loaded employee object?
When, where, how, does the ModelState get updated so that it knows that the employee object is full validated (i.e. has a primary key)?
Thank you