public ActionResult Edit(EditViewModel editViewModel) { if (editViewModel == null) { throw new HttpException(400, "Bad Request"); } var partner = PartnerService.FindById(editViewModel.PartnerId); if (partner == null) { throw new HttpException(404, "Not Found"); } partner.Name = editViewModel.Name; partner.Phone = editViewModel.Phone; partner.Fax = editViewModel.Fax; partner.Email = editViewModel.Email; partner.Address = editViewModel.Address; partner.Note = editViewModel.Note; partner.TaxCode = editViewModel.TaxCode; PartnerService.UpdatePartner(partner); TempData["PartnerId"] = partner.PartnerId; TempData["partnerName"] = partner.Name; TempData["Message"] = PartnersMessage.EditSuccess; return RedirectToAction("index", "partners"); }
public ActionResult Edit(int? id) { if (id == null) { throw new HttpException(400, "Bad Request"); } var partner = PartnerService.FindById(id.Value); if (partner == null) { throw new HttpException(404, "Not Found"); } var editViewModel = new EditViewModel() { PartnerId = partner.PartnerId, Name = partner.Name, Phone = partner.Phone, Fax = partner.Fax, Email = partner.Email, Address = partner.Address, Note = partner.Note, TaxCode = partner.TaxCode, }; return View(editViewModel); }