// GET: Customer/Delete/5 public ActionResult Delete(int id) { var customer = _unitOfWork.Customers.Get(id); var model = new CustomerViewModel() {FirstName = customer.FirstName, LastName = customer.LastName, Email = customer.Email}; return PartialView("_DeletePartial", model); }
public ActionResult Delete(int id, CustomerViewModel model) { try { var existingRecord = _unitOfWork.Customers.Get(id); _unitOfWork.Customers.Delete(existingRecord); _unitOfWork.SaveChanges(); return RedirectToAction("Index"); } catch { return PartialView("_DeletePartial"); } }
public ActionResult Create(CustomerViewModel model) { try { var customer = new Customer() { FirstName = model.FirstName, LastName = model.LastName, Email = model.Email.ToLower() }; _unitOfWork.Customers.Add(customer); _unitOfWork.SaveChanges(); return RedirectToAction("Index"); } catch { return PartialView("_CreateEditPartial"); } }
public ActionResult Edit(int id, CustomerViewModel model) { try { var existingRecord = _unitOfWork.Customers.Get(id); existingRecord.FirstName = model.FirstName; existingRecord.LastName = model.LastName; existingRecord.Email = model.Email; _unitOfWork.SaveChanges(); return RedirectToAction("Index"); } catch { return PartialView("_CreateEditPartial"); } }
// GET: Customer/Edit/5 public ActionResult Edit(int id) { var customer = _unitOfWork.Customers.Get(id); var model = new CustomerViewModel() { Id = customer.Id, FirstName = customer.FirstName, LastName = customer.LastName, Email = customer.Email }; return PartialView("_CreateEditPartial", model); }