public ActionResult DeleteConfirmed(int id) { Lotion lotion = db.Lotions.Find(id); db.Lotions.Remove(lotion); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult EditLotion(Lotion model) { if (ModelState.IsValid) { unitOfWork.Lotions.Edit(model); unitOfWork.Complete(); unitOfWork.Dispose(); return(RedirectToAction("Index", "Lotion")); } else { return(View(model)); } }
public ActionResult Edit([Bind(Include = "LotionId,TypeId,LabelId,ScentId,SizeId,Price,Discount,AddCBD,AddMagOil,IsFeatured,Photo1,Photo2,Photo3,Photo4,Photo5,Notes")] Lotion lotion) { if (ModelState.IsValid) { db.Entry(lotion).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.LabelId = new SelectList(db.Labels, "LabelId", "LabelDesc", lotion.LabelId); ViewBag.TypeId = new SelectList(db.Products, "TypeId", "ProductName", lotion.TypeId); ViewBag.ScentId = new SelectList(db.Scents, "ScentId", "ScentName", lotion.ScentId); ViewBag.SizeId = new SelectList(db.Sizes, "SizeId", "SizeDesc", lotion.SizeId); return(View(lotion)); }
// GET: Lotions/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Lotion lotion = db.Lotions.Find(id); if (lotion == null) { return(HttpNotFound()); } return(View(lotion)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Lotion lotion = db.Lotions.Find(id); if (lotion == null) { return(HttpNotFound()); } ViewBag.LabelId = new SelectList(db.Labels, "LabelId", "LabelDesc", lotion.LabelId); ViewBag.TypeId = new SelectList(db.Products, "TypeId", "ProductName", lotion.TypeId); ViewBag.ScentId = new SelectList(db.Scents, "ScentId", "ScentName", lotion.ScentId); ViewBag.SizeId = new SelectList(db.Sizes, "SizeId", "SizeDesc", lotion.SizeId); return(View(lotion)); }
public ActionResult AddLotion(Lotion model) { try { if (ModelState.IsValid) { unitOfWork.Lotions.Add(model); unitOfWork.Complete(); unitOfWork.Dispose(); return(RedirectToAction("Index", "Lotion")); } } catch (Exception ex) { //TODO: We want to show an error message return(View()); } return(View()); }