Пример #1
0
        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.FlavorTreat.Add(new FlavorTreat()
                {
                    FlavorID = FlavorID, TreatID = treat.TreatID
                });
            }
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #2
0
 public ActionResult Create(Flavor flavor)
 {
     _db.Flavors.Add(flavor);
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }