public ActionResult Create(ScoreCard scorecard) { // TODO: put in temp message that you need too refresh to see latest avg score if (ModelState.IsValid) { db.scorecard.Add(scorecard); db.SaveChanges(); CalculateAverageScore(scorecard.HoleID); if (Request.IsAjaxRequest()) { return PartialView("_ThanksForFeedback"); // return RedirectToAction("Hole", "ViewHoles", new { id = scorecard.hole.CourseID }); } return RedirectToAction("Index"); } ViewBag.HoleID = new SelectList(db.hole, "ID", "HoleNumber", scorecard.HoleID); return View(scorecard); }
public ActionResult Edit(ScoreCard scorecard) { if (ModelState.IsValid) { db.Entry(scorecard).State = EntityState.Modified; db.SaveChanges(); CalculateAverageScore(scorecard.HoleID); return RedirectToAction("Index"); } ViewBag.HoleID = new SelectList(db.hole, "ID", "HoleNumber", scorecard.HoleID); return View(scorecard); }