public ActionResult AddResult() { ViewBag.Title = "Add Result"; ViewBag.Message = "Add a result of a game"; var model = new GameResult(); model.DateOfGame = DateTime.Today; return View(model); }
public ActionResult AddResult(GameResult model) { if (ModelState.IsValid) { LeagueTableRepo.AddGame(model); Twitter.Tweet(model.TwitterResult); } return RedirectToAction("Index", "LeagueTable"); }
public ActionResult Complete(GameResult model) { if (ModelState.IsValid) { var game = ScheduleRepo.GetScheduledGame(model.ID, this.HttpContext.Application["Players"] as List<Player>); model.Player1SelectedItemId = game.Player1SelectedItemId; model.Player1 = game.Player1; model.Player2SelectedItemId = game.Player2SelectedItemId; model.Player2 = game.Player2; model.DateOfGame = game.DateOfGame; LeagueTableRepo.AddGame(model); ScheduleRepo.Delete(game.ID); Twitter.Tweet(model.TwitterCompleteScheduledGame); } return RedirectToAction("Index", "LeagueTable"); }
public static void AddGame(GameResult result) { if (ConfigurationManager.ConnectionStrings["DefaultConnection"] != null) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString)) { var sp = new SqlCommand("AddGame", con); sp.CommandType = CommandType.StoredProcedure; sp.Parameters.AddWithValue("DateOfGame", result.DateOfGame); sp.Parameters.AddWithValue("Player1", result.Player1SelectedItemId); sp.Parameters.AddWithValue("Player2", result.Player2SelectedItemId); sp.Parameters.AddWithValue("Player1Score", result.Player1Score); sp.Parameters.AddWithValue("Player2Score", result.Player2Score); sp.Parameters.AddWithValue("Comments", result.Comments); con.Open(); sp.ExecuteNonQuery(); } } }
public ActionResult Complete(int Id) { if (ModelState.IsValid) { var game = ScheduleRepo.GetScheduledGame(Id, this.HttpContext.Application["Players"] as List<Player>); ViewBag.Title = "Add Result"; ViewBag.Message = "Add a result of a scheduled game"; GameResult result = new GameResult(); result.DateOfGame = game.DateOfGame; result.Player1SelectedItemId = game.Player1SelectedItemId; result.Player1 = game.Player1; result.Player2SelectedItemId = game.Player2SelectedItemId; result.Player2 = game.Player2; return View(result); } return RedirectToAction("ListScheduleGames", "Schedule"); }