예제 #1
0
 public ActionResult Create(Treat treat, int FlavorId)
 {
     _db.Treats.Add(treat);
     if (FlavorId != 0)
     {
         _db.TreatFlavor.Add(new TreatFlavor()
         {
             FlavorId = FlavorId, TreatId = treat.TreatId
         });
     }
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
예제 #2
0
        public async Task <ActionResult> Create(Flavor flavor, int TreatId)
        {
            var userId      = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
            var currentUser = await _userManager.FindByIdAsync(userId);

            flavor.User = currentUser;
            _db.Flavors.Add(flavor);
            if (TreatId != 0)
            {
                _db.TreatFlavor.Add(new TreatFlavor()
                {
                    TreatId = TreatId, FlavorId = flavor.FlavorId
                });
            }
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult> Create(Treat treat, int FlavorId)
        {
            var userId      = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
            var currentUser = await _userManager.FindByIdAsync(userId);

            treat.User = currentUser;
            _db.Treats.Add(treat);

            if (FlavorId != 0)
            {
                _db.FlavorTreats.Add(new FlavorTreat()
                {
                    FlavorId = FlavorId, TreatId = treat.TreatId
                });
            }
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Create(Flavor flavor)
 {
     _db.Flavors.Add(flavor);
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
 public ActionResult Create(Treat treat)
 {
     _db.Treats.Add(treat);
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }