I have ViewModel, View which uses this viewmodel and controller
in view I have input fields like this:
@Html.EditorFor(model => model.TransitApplication.ApplicationDate)
and field name is TransitApplication_ApplicationDate
I want to update some data from view in database but there is one problem
controller update source
public ActionResult Update(int id, FormCollection collection)
{
string prefix = "TransitApplication";
TransitApplication transitApplication = transitApplicationRepozitory.GetById(id);
if (transitApplication == null)
return Content("Error! Not Found!");
if (TryUpdateModel(transitApplication, prefix))
{
if (ModelState.IsValid)
{
transitApplicationRepozitory.Update(transitApplication);
transitApplicationRepozitory.Save();
return RedirectToAction("Index");
}
}
return Content("Error!");
}
I want to take prefix (TransitApplication) name programmatically and not like I have string prefix = "TransitApplication";
some advice?