public ActionResult Edit(Models.Customer.AddViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var customer = _customerService.GetById(model.Id); if (customer == null) { return(View("_ErrorNotExist")); } customer.TC = model.TC; customer.Name = model.Name; customer.LastName = model.LastName; customer.Phone = model.Phone; var result = _customerService.Update(customer); if (result <= 0) { ViewBag.ErrorMessage = "Not Edited"; return(View(model)); } return(RedirectToAction(nameof(CustomerController.List))); }
public ActionResult Add(Models.Customer.AddViewModel model) { if (!ModelState.IsValid) { return(View(model)); } Data.Entity.Customer customer = new Data.Entity.Customer(); customer.TC = model.TC; customer.Name = model.Name; customer.LastName = model.LastName; customer.Phone = model.Phone; var result = _customerService.Add(customer); if (result > 0) { return(RedirectToAction(nameof(CustomerController.List))); } else { ViewBag.ErrorMessage = "Not Saved"; return(View(model)); } }