public ActionResult Add(City city) { City ObjCity = new City { CityName = city.CityName }; _context.Cities.Add(ObjCity); _context.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult AddCustomer(CustomerViewModel customerViewModel) { Customer ObjCustomer = new Customer { Name = customerViewModel.Name, Gender = customerViewModel.Gender, Details = customerViewModel.Details, RegistrationDate = DateTime.Now, CityId = customerViewModel.CityId }; _context.Customers.Add(ObjCustomer); _context.SaveChanges(); return(RedirectToAction("Index", "Customer")); }
public ActionResult DeleteConfirmed(Guid id) { try { repository.Delete(id); db.SaveChanges(); } catch (DataException) { return(RedirectToAction("DataError", "Error", new { area = "", message = "刪除錯誤" })); } return(RedirectToAction("Index")); }