public ActionResult Create() { CourtAssignment ca = new CourtAssignment(); if(Session["courtDate"] == null) Session["courtDate"] = "NewDate"; ca.defaultDate = Session["courtDate"].ToString(); string playcode = Session["PlayCode"].ToString(); if (playcode == "O") ViewBag.WebGridTitle = "OPUS Players"; else ViewBag.WebGridTitle = "Scramble Players"; //Setup data for the name dropdowns if (TempData["ThisWeeksPlayers"] != null) { ViewBag.Players = TempData["ThisWeeksPlayers"]; TempData["ThisWeeksPlayers"] = ViewBag.Players; ViewBag.PlayerWebGridInfo = TempData["PlayerWebGridInfo"]; TempData["PlayerWebGridInfo"] = ViewBag.PlayerWebGridInfo; } else { ViewBag.Players = util.GetPlayersSelectList(Session["Group"].ToString(), playcode); TempData["PlayersSelectList"] = ViewBag.Players; ViewBag.PlayerWebGridInfo = util.GetOpusPlayerInfo(Session["Group"].ToString(), playcode); TempData["PlayerWebGridInfo"] = ViewBag.PlayerWebGridInfo; } ca.Court = null; //Get Previous Court Assignments //Check if date is not new date and get appropriate previous courts List<SelectListItem> dates = util.GetCourtDates(Session["Group"].ToString()) as List<SelectListItem>; string pcd = ""; if(Session["previousCourtDate"] != null) pcd = Session["previousCourtDate"].ToString(); string cd = Session["courtDate"].ToString(); if (Session["courtDate"].ToString() == "NewDate") { Session["previousCourtDate"] = dates.Last().Text; } else if(Session["previousCourtDate"] == null) { Session["previousCourtDate"] = Session["courtDate"]; GetPreviousCourtDate(dates); } else if (Session["courtDate"].ToString() == Session["previousCourtDate"].ToString()) { GetPreviousCourtDate(dates); } if (ViewBag.PreviousAssign == null) { PreviousCourtAssignments(Session["previousCourtDate"].ToString()); } return View(ca); }
public void AddCourtToScoring(OpusContext db1, OpusContext db3, string date, CourtAssignment item) { //Load a record into Scores table for each player (4 per item found) //The data being used comes from the CourtAssignment data which keeps player namses as First, Last (STC Rank) //The code below just grabs First and Last for use in the Scoring table. int id = Convert.ToInt32(item.Player1ID); OpusPlayer player = db3.OpusPlayers.Single(q => q.PlayerID == id); Scoring sRow = new Scoring { Date = date, First = player.First, Last = player.Last, Group = player.Group, STCPlayerID = player.PlayerID, Name = item.Player1 }; db1.Scores.Add(sRow); id = Convert.ToInt32(item.Player2ID); player = db3.OpusPlayers.Single(q => q.PlayerID == id); sRow = new Scoring { Date = date, First = player.First, Last = player.Last, Group = player.Group, STCPlayerID = player.PlayerID, Name = item.Player2 }; db1.Scores.Add(sRow); id = Convert.ToInt32(item.Player3ID); player = db3.OpusPlayers.Single(q => q.PlayerID == id); sRow = new Scoring { Date = date, First = player.First, Last = player.Last, Group = player.Group, STCPlayerID = player.PlayerID, Name = item.Player3 }; db1.Scores.Add(sRow); id = Convert.ToInt32(item.Player4ID); player = db3.OpusPlayers.Single(q => q.PlayerID == id); sRow = new Scoring { Date = date, First = player.First, Last = player.Last, Group = player.Group, STCPlayerID = player.PlayerID, Name = item.Player4 }; db1.Scores.Add(sRow); }
private bool ShouldDelete(string name, CourtAssignment assigned) { if (name != assigned.Player1 && name != assigned.Player2 && name != assigned.Player3 && name != assigned.Player4) return true; else return false; }