public ActionResult Edit(EditPartnerModel model, int id, HttpPostedFileBase Logo) { try { if (ModelState.IsValid) { Partner partner = new Partner() { PartnerID = id, Name = model.Name, Address = model.Address, ContactName = model.ContactName, UpdatedUserID = SessionManager.UserInfo.UserID, Description = model.Description, PartnerType = model.PartnerType, PhoneNumber1 = model.PhoneNumber1, PhoneNumber2 = model.PhoneNumber2, LogoPath = model.LogoPath, }; PartnerService service = new PartnerService(); service.Edit(partner, Logo); return RedirectToAction("Index", "Partner"); } // TODO: Add update logic here } catch (Exception ex) { ModelState.AddModelError("Error500", ex.Message); } return View(model); }
public ActionResult Edit(int id) { PartnerService service = new PartnerService(); var item = service.FirstOrDefault(p => p.PartnerID == id); if (item != null) { EditPartnerModel model = new EditPartnerModel() { Id = id, Address = item.Address, ContactName = item.ContactName, Description = item.Description, LogoPath = item.LogoPath, Name = item.Name, PartnerType = item.PartnerType, PhoneNumber1 = item.PhoneNumber1, PhoneNumber2 = item.PhoneNumber2 }; return View(model); } return View(); }