I have a main Contact and ContactViewModel . How do I get contact model and update it to the database ?
[HttpPost]
public ActionResult EditContact(ContactFormViewModel contactView) {
}
I was doing like this before I needed ViewModel
[HttpPost]
public ActionResult EditContact(int id, FormCollection collection) {
Contact contact = repository.GetContactById(id);
if (TryUpdateModel(contact, "Contact")) {
repository.Save();
return RedirectToAction("Index");
return View(new ContactFormView Model(contact));
}
}