public ActionResult Edit(ClientViewModel model) { if (ModelState.IsValid) {//this one is a bit different because we have embedded Contacts that are not posted back from the same form. _repository.Update(model.Client); return RedirectToAction("Edit", new { id = model.Client.Id }); } else { return View(model.Client.Id); } }
public ActionResult Create(ClientViewModel model) { if (ModelState.IsValid) { _repository.Insert<Client>(model.Client); return RedirectToAction("Index"); } else { return View(); } }
public ActionResult Edit(string id) { MXTimer timing = new MXTimer(); ClientViewModel model = new ClientViewModel { Client = _repository.GetOne<Client>(id), }; ViewBag.QueryTime = timing.Finish(); return View(model); }
public ActionResult Create(ClientViewModel model) { Client client = _repository.GetOne<Client>(model.Client.Id); if (client.Contacts == null) { client.Contacts = new List<Contact>(); } model.Client.Contacts[0].Id = MXMongoIdGenerator.NewId; client.Contacts.Add(model.Client.Contacts[0]); _repository.Update<Client>(client); return RedirectToAction("Index", new { id = model.Client.Id }); }