public ActionResult ChangeItem(int id, int qty) { if (qty >= 0) { var cart = new Cart { CartId = id, Quantity = qty }; _db.Carts.Attach(cart); _db.Entry(cart).Property(x => x.Quantity).IsModified = true; _db.SaveChanges(); } return(RedirectToAction("Create")); }
public ActionResult Edit(Treat treat, int FlavorId) { if (FlavorId != 0) { bool tf = _db.FlavorTreat.Any(x => x.FlavorId == FlavorId && x.TreatId == treat.TreatId); if (!tf) { _db.FlavorTreat.Add(new FlavorTreat() { FlavorId = FlavorId, TreatId = treat.TreatId }); } } _db.Entry(treat).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Flavor flavor, int TreatId) { if (TreatId != 0) { bool tf = _db.FlavorTreat.Any(x => x.FlavorId == flavor.FlavorId && x.TreatId == TreatId); if (!tf) { _db.FlavorTreat.Add(new FlavorTreat() { TreatId = TreatId, FlavorId = flavor.FlavorId }); } } _db.Entry(flavor).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }