// GET: Customer/Edit/5 public ActionResult Edit(int id) { Lib.Customer libRest = CRepo.GetCustomerById(id); var webRest = new Customer { CustomerId = libRest.Id, FirstName = libRest.FirstName, LastName = libRest.LastName, DefaultStoreId = libRest.DefaultStoreId }; return(View()); }
// GET: Customer/Edit/5 public ActionResult Edit(int id) { //Lib.Restaurant libRest = Repo.GetRestaurantById(id); //var webRest = new Restaurant //{ // Id = libRest.Id, // Name = libRest.Name //}; Lib.Customer libRest = CRepo.GetCustomerById(id); var webRest = new Customer { CustomerId = libRest.Id, FirstName = libRest.FirstName, LastName = libRest.LastName, DefaultStoreId = libRest.DefaultStoreId }; return(View()); }
//[FromRoute] int id, [Bind("Name")]Restaurant restaurant public ActionResult Edit([FromRoute] int id, [Bind("Name")] Customer customer) { try { // edit does not work if (ModelState.IsValid) { Lib.Customer libRest = CRepo.GetCustomerById(id); libRest.FirstName = customer.FirstName; libRest.LastName = customer.LastName; libRest.DefaultStoreId = customer.DefaultStoreId; CRepo.Save(); return(RedirectToAction(nameof(Index))); } return(View(customer)); } catch { return(View(customer)); } }