public ActionResult Create([Bind(Include = "ShopAssistantName")] ShopAssistantDTO shopAssistantDTO) { IUnitOfWork database = new EFUnitOfWork(); var shopAssistant = new ShopAssistantDAL { ShopAssistantName = shopAssistantDTO.ShopAssistantName, Id = shopAssistantDTO.Id }; try { if (ModelState.IsValid) { database.ShopAssistants.Insert(shopAssistant); database.ShopAssistants.Save(); return(RedirectToAction("Index")); } } catch (DataException /* dex */) { //Log the error (uncomment dex variable name after DataException and add a line here to write a log. ModelState.AddModelError(string.Empty, "Unable to save changes. Try again, and if the problem persists contact your system administrator."); } return(View(shopAssistantDTO)); }
// // GET: /ShopAssistant/Edit/5 public ActionResult Edit(int id) { Service service = new Service(); ShopAssistantDTO shopAssistan = service.GetShopAssistant(id); return(View(shopAssistan)); }
// // GET: /ShopAssistant/Delete/5 public ActionResult Delete(bool?saveChangesError = false, int id = 0) { Service service = new Service(); if (saveChangesError.GetValueOrDefault()) { ViewBag.ErrorMessage = "Delete failed. Try again, and if the problem persists see your system administrator."; } ShopAssistantDTO shopAssistan = service.GetShopAssistant(id); return(View(shopAssistan)); }