public ActionResult Delete(MAYANH pr) { MAYANH mAYANH = new MAYANH(); mAYANH = db.MAYANHs.Find(pr.IDMAY); if (mAYANH != null) { db.MAYANHs.Remove(pr); db.SaveChanges(); } return(RedirectToAction("List")); }
public ActionResult Create(MAYANH pr, HttpPostedFileBase hinhMinhHoa) { if (hinhMinhHoa != null && hinhMinhHoa.ContentLength > 0) { var TenAnh = Path.GetFileName(hinhMinhHoa.FileName); var DuongDan = Path.Combine(Server.MapPath("~/Content/images/"), TenAnh); pr.HINHANH = TenAnh; hinhMinhHoa.SaveAs(DuongDan); } db.MAYANHs.Add(pr); db.SaveChanges(); return(RedirectToAction("List")); }
public ActionResult Delete(int id) { if (Session["us"] == null) { return(RedirectToAction("Login")); } else { MAYANH pr = new MAYANH(); pr = db.MAYANHs.Find(id); return(View(pr)); } }
public ActionResult Edit(int id) { if (Session["us"] == null) { return(RedirectToAction("Login")); } else { MAYANH pr = new MAYANH(); pr = db.MAYANHs.Find(id); List <LOAIMAY> cateLoaiMay = db.LOAIMAYs.ToList(); SelectList cateListLoaiMay = new SelectList(cateLoaiMay, "IDLOAIMAY", "TENLMAY"); ViewBag.IDLOAIMAY = cateListLoaiMay; return(View(pr)); } }
// GET: ShoppingCart public ActionResult Add(int id) { ShoppingCart cart = (ShoppingCart)Session["cart"]; if (cart == null) { cart = new ShoppingCart(); } ShopModelsData db = new ShopModelsData(); MAYANH pr = db.MAYANHs.Find(id); if (pr != null) { cart.InsertItem(pr.IDMAY, pr.TENMAY, (double)pr.DONGIA); } Session["cart"] = cart; return(Redirect(Request.UrlReferrer.ToString())); }
public ActionResult Edit(MAYANH pr, HttpPostedFileBase hinhMinhHoa) { MAYANH mAYANH = new MAYANH(); mAYANH = db.MAYANHs.Find(pr.IDMAY); if (mAYANH != null) { if (hinhMinhHoa != null && hinhMinhHoa.ContentLength > 0) { var TenAnh = Path.GetFileName(hinhMinhHoa.FileName); var DuongDan = Path.Combine(Server.MapPath("~/Content/images/"), TenAnh); mAYANH.HINHANH = TenAnh; hinhMinhHoa.SaveAs(DuongDan); } mAYANH.TENMAY = pr.TENMAY; mAYANH.MOTA = pr.MOTA; mAYANH.DONGIA = pr.DONGIA; mAYANH.IDLOAIMAY = pr.IDLOAIMAY; db.SaveChanges(); } return(RedirectToAction("List")); }