public ActionResult Submit(SubmitGameModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                // submit game .. then go to standings page  ?
                GameLogic.Submit(model);
                TeamLogic.UpdateTeamSeasonStatRowsForGame(model);

                string winningPlayers = Request.Form["winningplayer"];
                string losingPlayers = Request.Form["losingplayer"];
                string[] winners = winningPlayers.Split(',');
                string[] losers = losingPlayers.Split(',');

                for (int i = 0; i < winners.Length; i++)
                {
                    PlayerSeasonStat statRow = new PlayerSeasonStat();
                    statRow.UserID = Convert.ToInt32(winners[i]);
                    statRow.Season = LeagueLogic.GetSeason(TeamLogic.GetLeagueID(Convert.ToInt32(model.WinningTeamID)));
                    AccountLogic.UpdatePlayerSeasonStats(statRow, model);
                }

                for (int i = 0; i < losers.Length; i++)
                {
                    PlayerSeasonStat statRow = new PlayerSeasonStat();
                    statRow.UserID = Convert.ToInt32(losers[i]);
                    statRow.Season = LeagueLogic.GetSeason(TeamLogic.GetLeagueID(Convert.ToInt32(model.WinningTeamID)));
                    AccountLogic.UpdatePlayerSeasonStats(statRow, model);
                }

                SubmitGameModel newModel = new SubmitGameModel();
                newModel.SetWinningTeamDDL(Convert.ToInt32(Session["TeamID"]));
                newModel.SetWinningPlayersList(Convert.ToInt32(Session["TeamID"]));
                return View(newModel);
            }

            model.SetWinningTeamDDL(Convert.ToInt32(Session["TeamID"]));
            model.SetWinningPlayersList(Convert.ToInt32(Session["TeamID"]));
            return View(model);
        }
        public static void UpdatePlayerSeasonStats(PlayerSeasonStat stats, SubmitGameModel game)
        {
            int teamID = GetTeamID(stats.UserID);
            int points = GameLogic.GetPointsForGameType(Convert.ToInt32(game.GameTypeID));
            string sql = @"declare @Count int
                            set @Count = (select count(pss.PlayerSeasonStatID)
                                            from PlayerSeasonStats pss
                                            where UserID = @UserID
                                                and Season = @Season)
                           if @Count = 0
                           begin
                               insert into PlayerSeasonStats (UserID, Wins, Losses, Season, Points)
                                values (@UserID,
                                        case @Win when 1 then 1 else 0 end,
                                        case @Win when 1 then 0 else 1 end,
                                        @Season, @Points)
                           end
                           else
                               if @Win = 1
                               begin
                                    update PlayerSeasonStats
                                    set Wins = Wins + 1, Points = Points + @Points
                                    where UserID = @UserID and Season = @Season
                               end
                               else
                                    update PlayerSeasonStats
                                    set Losses = Losses + 1
                                    where UserID = @UserID and Season = @Season";

            using (SqlConnection conn = new SqlConnection(Main.GetDSN()))
            {
                SqlCommand command = new SqlCommand(sql, conn);
                command.Parameters.AddWithValue("@UserID", stats.UserID);
                command.Parameters.AddWithValue("@Season", stats.Season);
                command.Parameters.AddWithValue("@Points", points);
                command.Parameters.AddWithValue("@Win", teamID == Convert.ToInt32(game.WinningTeamID));
                conn.Open();
                command.ExecuteNonQuery();
                conn.Close();
            }
        }