public ActionResult Create(Customer customer) { try { if (ModelState.IsValid) { Lib.Location libStore = StoreRepo.GetAllStores().First(); CustomerRepo.AddCustomer(new Lib.Customer { FirstName = customer.FirstName, LastName = customer.LastName, Birthday = customer.Birthday, StoreId = libStore.LocationId }); CustomerRepo.Save(); return(RedirectToAction(nameof(Index))); } return(View(customer)); } catch { return(View()); } }
// GET: Store/Delete/5 public ActionResult Delete(int id) { Lib.Location libStore = StoreRepo.GetStoreById(id); var webStore = new Store { Id = libStore.LocationId, Name = libStore.Name, }; return(View(libStore)); }
// GET: Store/Details/5 public ActionResult Details(int id) { Lib.Location libStore = StoreRepo.GetStoreById(id); var webStore = new Store { Id = libStore.LocationId, Name = libStore.Name, }; StoreViewModel svm = new StoreViewModel(libStore); return(View(svm)); }
// GET: Customer/Details/5 public ActionResult Details(int id) { Lib.Customer libCustomer = CustomerRepo.GetCustomerById(id); Lib.Location libStore = StoreRepo.GetAllStores().First(); var webCust = new Customer { Id = libCustomer.Id, FirstName = libCustomer.FirstName, LastName = libCustomer.LastName, Birthday = libCustomer.Birthday, StoreId = libCustomer.StoreId }; CustomerViewModel cvm = new CustomerViewModel(libCustomer, libStore); return(View(cvm)); }