public ActionResult Create([Bind(Include = "id,FirstName,LastName,TuesdayLeague,WednesdayLeague,shortname")] Player player) { if (ModelState.IsValid) { db.Players.Add(player); try { db.SaveChanges(); return(RedirectToAction("Index")); } 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, "Insert failed"); } } return(View(player)); }
public ActionResult Create([Bind(Include = "id,GameDate,IsCancelled")] TuesdaySchedule tuesdaySchedule) { if (ModelState.IsValid) { db.TuesdaySchedules.Add(tuesdaySchedule); try { db.SaveChanges(); return(RedirectToAction("Index")); } 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, "Insert failed"); } } return(View(tuesdaySchedule)); }
public ActionResult RemoveLead(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TuesdayTeam tuesdayTeam = db.TuesdayTeams.Find(id); if (tuesdayTeam == null) { return(HttpNotFound()); } tuesdayTeam.Lead = null; db.Entry(tuesdayTeam).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult MoveUp(int id, int weekid) { var tuesdayMatches = db.TuesdayMatches.Where(x => x.GameDate == weekid).OrderBy(x => x.Rink); var match = tuesdayMatches.First(x => x.Rink == id); var match1 = tuesdayMatches.First(x => x.Rink == id + 1); match1.Rink = id; match.Rink = id + 1; db.Entry(match).State = EntityState.Modified; db.Entry(match1).State = EntityState.Modified; try { db.SaveChanges(); } catch (Exception e) { ErrorSignal.FromCurrentContext().Raise(e); } return(RedirectToAction("Index", new { ScheduleID = weekid })); }
public ActionResult RemoveLead(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } WednesdayTeam WednesdayTeam = db.WednesdayTeams.Find(id); if (WednesdayTeam == null) { return(HttpNotFound()); } WednesdayTeam.Lead = null; db.Entry(WednesdayTeam).State = EntityState.Modified; try { db.SaveChanges(); } catch (Exception e) { ErrorSignal.FromCurrentContext().Raise(e);; } return(RedirectToAction("Index")); }