// AddToCart public async Task <ActionResult> AddToCart(int id) { var userId = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value; var currentUser = await _userManager.FindByIdAsync(userId); _db.Carts.Add(new Cart { FlavorTreatId = id, OrderId = 0, Quantity = 0, User = currentUser }); _db.SaveChanges(); return(RedirectToAction("Create")); }
public ActionResult Create(Treat treat, int FlavorId) { _db.Treats.Add(treat); if (FlavorId != 0) { _db.FlavorTreat.Add(new FlavorTreat() { TreatId = treat.TreatId, FlavorId = FlavorId }); } _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(Flavor flavor, int TreatId) { _db.Flavors.Add(flavor); if (TreatId != 0) { _db.FlavorTreat.Add(new FlavorTreat() { TreatId = TreatId, FlavorId = flavor.FlavorId }); } _db.SaveChanges(); return(RedirectToAction("Index")); }