public ActionResult EditPost(int id, string returnUrl) { var customer = _customerService.Customers.FirstOrDefault(x => x.Id == id && x.IsActive); if (customer == null) { return(RedirectToAction("Index", "Home")); } var viewModel = new CustomerEdit(customer); if (!TryUpdateModel(viewModel) || !ModelState.IsValid) { return(View(viewModel)); } try { var model = viewModel.ToCustomer(); _customerService.Create(model); } catch (Exception ex) { return(View(viewModel)); throw ex; } //return RedirectToAction("Create", "Order"); return(Redirect(returnUrl)); }
public ActionResult CreatePost(string returnUrl) { var viewModel = new CustomerEdit(new Data.Models.Customer()); if (!TryUpdateModel(viewModel) || !ModelState.IsValid) { return(View(viewModel)); } try { var model = viewModel.ToCustomer(); _customerService.Create(model); } catch (Exception ex) { return(View(viewModel)); throw ex; } //return RedirectToAction("Create", "Order"); return(Redirect(returnUrl)); }