public ActionResult Create(Incentive incentive) { if (ModelState.IsValid) { db.Incentives.Add(incentive); db.SaveChanges(); _uaService.CalculateIncentives(db.Users.Find(incentive.UserId).Username); return RedirectToAction("Index", new { Username = db.Users.Find(incentive.UserId).Username }); } ViewBag.UserId = new SelectList(db.Users, "UserId", "Username", incentive.UserId); return View("index", new { Username = db.Users.Find(incentive.UserId).Username }); }
public ActionResult Edit(Incentive incentive) { var username = db.Users.Find(incentive.UserId).Username; if (ModelState.IsValid) { db.Entry(incentive).State = EntityState.Modified; db.SaveChanges(); _uaService.CalculateIncentives(username); return RedirectToAction("index", new { username = username }); } ViewBag.UserId = new SelectList(db.Users, "UserId", "Username", incentive.UserId); return RedirectToAction("index", new { username = username }); }