예제 #1
0
        // 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"));
        }
예제 #2
0
 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"));
 }
예제 #3
0
 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"));
 }