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")); }
public ActionResult Create(Flavor flavor) { _db.Flavors.Add(flavor); _db.SaveChanges(); return(RedirectToAction("Index")); }