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.FlavorTreat.Add(new FlavorTreat()
                {
                    TreatId = TreatId, FlavorId = flavor.FlavorId
                });
            }
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
 public ActionResult Create(Treat treat)
 {
     _db.Treats.Add(treat);
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }