public ActionResult Scoring(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } WednesdayMatch WednesdayMatch = db.WednesdayMatches.Find(id); if (WednesdayMatch == null) { return(HttpNotFound()); } var list = new List <ForfeitViewModel>(3) { new ForfeitViewModel() { value = 1, text = "no forfeit" }, new ForfeitViewModel() { value = 2, text = $"{WednesdayMatch.Team1.ToString()} - ({WednesdayMatch.WednesdayTeam.Player.NickName}, {WednesdayMatch.WednesdayTeam.Player1.NickName}, {WednesdayMatch.WednesdayTeam.Player2.NickName})" }, new ForfeitViewModel() { value = 3, text = $"{WednesdayMatch.Team2.ToString()} - ({WednesdayMatch.WednesdayTeam1.Player.NickName}, {WednesdayMatch.WednesdayTeam1.Player1.NickName}, {WednesdayMatch.WednesdayTeam1.Player2.NickName})" } }; ViewBag.Forfeit = new SelectList(list, "value", "text", WednesdayMatch.Forfeit); return(View(WednesdayMatch)); }
public ActionResult Scoring([Bind(Include = "id,GameDate,Rink,Team1,Team2,Team1Score,Team2Score, Forfeit")] WednesdayMatch WednesdayMatch) { if (ModelState.IsValid) { db.Entry(WednesdayMatch).State = EntityState.Modified; try { db.SaveChanges(); return(RedirectToAction("Index", new { ScheduleID = WednesdayMatch.GameDate })); } catch (System.Data.Entity.Infrastructure.DbUpdateException e) { ErrorSignal.FromCurrentContext().Raise(e); Exception ex = e; while (ex.InnerException != null) { ex = ex.InnerException; } ModelState.AddModelError(string.Empty, ex.Message); } catch (Exception e) { ErrorSignal.FromCurrentContext().Raise(e); ModelState.AddModelError(string.Empty, "Edit failed"); } } var list = new List <ForfeitViewModel>(3) { new ForfeitViewModel() { value = 1, text = "no forfeit" }, new ForfeitViewModel() { value = 2, text = $"{WednesdayMatch.Team1.ToString()} - ({WednesdayMatch.WednesdayTeam.Player.NickName}, {WednesdayMatch.WednesdayTeam.Player1.NickName}, {WednesdayMatch.WednesdayTeam.Player2.NickName})" }, new ForfeitViewModel() { value = 3, text = $"{WednesdayMatch.Team2.ToString()} - ({WednesdayMatch.WednesdayTeam1.Player.NickName}, {WednesdayMatch.WednesdayTeam1.Player1.NickName}, {WednesdayMatch.WednesdayTeam1.Player2.NickName})" } }; ViewBag.Forfeit = new SelectList(list, "value", "text", WednesdayMatch.Forfeit); return(View(WednesdayMatch)); }