Exemplo n.º 1
0
 public static void EditScheduleGame(Game result)
 {
     if (ConfigurationManager.ConnectionStrings["DefaultConnection"] != null)
     {
         using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
         {
             var sp = new SqlCommand("EditScheduleGame", con);
             sp.CommandType = CommandType.StoredProcedure;
             sp.Parameters.AddWithValue("ID", result.ID);
             sp.Parameters.AddWithValue("DateOfGame", result.DateOfGame);
             sp.Parameters.AddWithValue("Player1", result.Player1SelectedItemId);
             sp.Parameters.AddWithValue("Player2", result.Player2SelectedItemId);
             con.Open();
             sp.ExecuteNonQuery();
         }
     }
 }
        public ActionResult Edit(Game model)
        {
            if (ModelState.IsValid)
            {
                ScheduleRepo.EditScheduleGame(model);
                Twitter.Tweet(model.TwitterEdited);
            }

            return RedirectToAction("ListScheduledGames", "Schedule");
        }
        public ActionResult ScheduleGame()
        {
            ViewBag.Title = "Schedule";
            ViewBag.Message = "Schedule a game to be played";

            var model = new Game();
            model.DateOfGame = DateTime.Today;

            return View(model);
        }
Exemplo n.º 4
0
        public static List<Game> GetScheduledGames(List<Player> Players)
        {
            if (ConfigurationManager.ConnectionStrings["DefaultConnection"] != null)
            {
                var table = new List<Game>();
                using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
                {
                    SqlDataAdapter da = new SqlDataAdapter("select * from vScheduleGames ORDER BY ScheduledDate", con);
                    DataSet ds = new DataSet();
                    da.Fill(ds);
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        var item = new Game()
                        {
                            ID = int.Parse(dr["ID"].ToString()),
                            DateOfGame = DateTime.Parse(dr["ScheduledDate"].ToString()),
                            Player1SelectedItemId = int.Parse(dr["Player1"].ToString()),
                            Player2SelectedItemId = int.Parse(dr["Player2"].ToString()),
                        };
                        table.Add(item);
                    }

                }
                return table;
            }

            return null;
        }