public ActionResult DeleteConfirmed(Offer offer) { int curShopId = -1; if (Session[Helper.ShopId] != null) curShopId = (int) Session[Helper.ShopId]; if (Helper.Roles.ModeratorRoles.Any(role => User.IsInRole(role)) || offer.ShopId == curShopId) { _db.Entry(offer).State = EntityState.Deleted; _db.SaveChanges(); return RedirectToAction("RedirectedBack", "Products"); } return View("Error"); }
public ActionResult Create(Offer offer) { int curShopId = -1; if (Session[Helper.ShopId] != null) curShopId = (int) Session[Helper.ShopId]; if (offer.ShopId == curShopId) { offer.LastUpdate = DateTime.Now; if (ModelState.IsValid) { _db.Offers.Add(offer); _db.SaveChanges(); return RedirectToAction("RedirectedBack", "Products"); } return View(offer); } return View("Error"); }
public ActionResult Edit(int productId, int shopId) { Offer offer = _db.Offers.Find(productId, shopId); if (offer == null) offer = new Offer { ProductId = productId, ShopId = shopId }; return View(offer); }