internal void Edit(CHEF chef) { using (entity = new klassycafeEntities()) { chefRepo = new GenericRepo <CHEF>(entity); chefRepo.Update(chef); chefRepo.Save(); } }
internal void Add(CHEF chef) { using (entity = new klassycafeEntities()) { chefRepo = new GenericRepo <CHEF>(entity); chefRepo.Insert(chef); chefRepo.Save(); } }
public ActionResult Chef_Remove(int ID) { if (Session["UserId"] == null) { return(RedirectToAction("Login")); } CHEF c = chefDA.GetById(ID); return(View(c)); }
public ActionResult Chef_Edit(int ID) { if (Session["UserId"] == null) { return(RedirectToAction("Login")); } CHEF chef = chefDA.GetById(ID); PopulateStateDropdownList(chef.STATE_ID); return(View(chef)); }
public ActionResult RemoveChefForm(CHEF chef) { try { chefDA.Remove(chef.ID); return(RedirectToAction("Chefs", "Admin")); } catch (Exception ex) { ViewBag.Error = "Try Again."; PopulateStateDropdownList(chef.STATE_ID); return(View("Chef_Remove", chef)); } }
internal CHEFLIST GetByIdForList(int id) { using (entity = new klassycafeEntities()) { chefRepo = new GenericRepo <CHEF>(entity); stateRepo = new GenericRepo <STATE>(entity); CHEF chef = chefRepo.FindByID(id); return(new CHEFLIST() { chef = chef, stateName = stateRepo.FindByID(chef.STATE_ID).NAME }); } }
public ActionResult EditChefForm(CHEF chef) { try { if (ModelState.IsValid) { CHEF c = chefDA.GetById(chef.ID); if (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0) { if (System.IO.File.Exists(Server.MapPath("~/Content/images/chef/" + chef.PICTURE))) { System.IO.File.Delete(Server.MapPath("~/Content/images/chef/" + chef.PICTURE)); } string dosyaAdi = Guid.NewGuid().ToString().Replace("-", ""); string uzanti = Path.GetExtension(Request.Files[0].FileName); string tamYolYeri = "~/Content/images/chef/" + dosyaAdi + uzanti; Request.Files[0].SaveAs(Server.MapPath(tamYolYeri)); chef.PICTURE = dosyaAdi + uzanti; } else { chef.PICTURE = c.PICTURE; } chefDA.Edit(chef); return(RedirectToAction("Chefs", "Admin")); } else { ViewBag.Error = "Try Again."; PopulateStateDropdownList(chef.STATE_ID); return(View("Chef_Edit", chef)); } } catch (Exception ex) { ViewBag.Error = "Try Again."; PopulateStateDropdownList(chef.STATE_ID); return(View("Chef_Edit", chef)); } }
public ActionResult AddChefForm(CHEF chef) { try { if (ModelState.IsValid) { if (Request.Files.Count > 0) { string dosyaAdi = Guid.NewGuid().ToString().Replace("-", ""); string uzanti = Path.GetExtension(Request.Files[0].FileName); string tamYolYeri = "~/Content/images/chef/" + dosyaAdi + uzanti; Request.Files[0].SaveAs(Server.MapPath(tamYolYeri)); chef.PICTURE = dosyaAdi + uzanti; } else { ViewBag.Error = "Add Image."; PopulateStateDropdownList(); return(View("Chef_Add", chef)); } chefDA.Add(chef); return(RedirectToAction("Chefs", "Admin")); } else { ViewBag.Error = "Try Again."; PopulateStateDropdownList(chef.STATE_ID); return(View("Chef_Add", chef)); } } catch (Exception ex) { ViewBag.Error = "Try Again."; PopulateStateDropdownList(chef.STATE_ID); return(View("Chef_Add", chef)); } }