Exemplo n.º 1
0
        private void UpdatePlayoffGame(int scheduleNo, int gameNo)
        {
            try
            {
                if (gameNo > 0)
                {
                    var vm = new ScheduleGamesVM();
                    var game = vm.GetPlayoffByScheduleAndGameNo(scheduleNo, gameNo);
                    if (game != null)
                    {
                        game.GameDate = ConcatDateTime(mskDate.Text, txtTime.Text);
                        game.GameTime = txtTime.Text;
                        game.LocationNumber = Convert.ToInt32(cmbVenues.SelectedItem.Value);
                        game.HomeTeam = txtHome.Text;
                        game.VisitingTeam = txtVisitor.Text;
                        game.Descr = txtDescr.Text;
                        game.DivisionId = Convert.ToInt32(ddlDivisions.SelectedValue);

                        using (var db = new CSBCDbContext())
                        {
                            var rep = new SchedulePlayoffRepository(db);
                            rep.Update(game);
                            db.SaveChanges();
                        }
                    }
                }
                else
                {
                    var date = ConcatDateTime(mskDate.Text, txtTime.Text);

                    ScheduleGamesVM.AddPlayoffGame(scheduleNo, date, txtTime.Text,
                        Convert.ToInt32(cmbVenues.SelectedItem.Value), txtHome.Text, txtVisitor.Text, txtDescr.Text,Convert.ToInt32(cmbDivisions.SelectedValue));
                }

            }
            catch (Exception e)
            {
                lblError.Text = "Update Regular Season Game:" + e.Message;
            }
        }
Exemplo n.º 2
0
        private void UpdateRegularSeasonGame(int scheduleNo, int gameNo)
        {
            var vm = new ScheduleGamesVM();
            var game = vm.GetByScheduleAndGameNo(scheduleNo, gameNo);

            try
            {
                game.GameDate = (DateTime)ConcatDateTime(mskDate.Text, txtTime.Text);
                game.GameTime = txtTime.Text;
                game.LocationNumber = Convert.ToInt32(cmbVenues.SelectedItem.Value);
                game.HomeTeamNumber = (int)ScheduleGamesVM.GetScheduleTeamNumberFromTeamNumber(scheduleNo, Convert.ToInt32(txtHome.Text));
                game.VisitingTeamNumber = (int)ScheduleGamesVM.GetScheduleTeamNumberFromTeamNumber(scheduleNo, Convert.ToInt32(txtVisitor.Text));
                if (game.VisitingTeamScore == null)
                    game.VisitingTeamScore = -1;
                else
                    game.VisitingTeamScore = game.VisitingTeamScore;
                if (game.HomeTeamScore == null)
                    game.HomeTeamScore = -1;
                else
                    game.HomeTeamScore = game.HomeTeamScore;
                game.DivisionId = Int32.Parse(ddlDivisions.SelectedValue);
                game.SeasonId = Master.SeasonId;

                using (var db = new CSBCDbContext())
                {
                    new ScheduleGameRepository(db).Update(game);
                    db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                lblError.Text = "Update Regular Season Game:" + e.Message;
            }
        }
Exemplo n.º 3
0
        private void LoadGameDetail(ScheduleGamesVM game)
        {
            ddlDivisions.SelectedValue = game.DivisionId.ToString();
            mskDate.Text = game.GameDate.ToShortDateString();
            txtTime.Text = game.GameTime;
            //cmbVenues.SelectedItem.Value = game.LocationNumber.ToString();
            cmbVenues.SelectedValue = game.LocationNumber.ToString();

            if (game.GameType == ScheduleGamesVM.GameTypes.Playoff)
            {
                txtHome.Text = game.HomeTeam;
                txtVisitor.Text = game.VisitorTeam;
                txtDescr.Text = game.Description;
            }
            else
            {
                txtHome.Text = game.HomeTeamNo.ToString();
                txtVisitor.Text = game.VisitorTeamNo.ToString();
            }
        }
Exemplo n.º 4
0
        private void LoadRegularSeasonGames()
        {
            try
            {
                List<ScheduleGamesVM> games;
                var vm = new ScheduleGamesVM();

                if (checkAllDates.Checked)
                {
                    games = vm.GetGames(Convert.ToInt32(cmbDivisions.SelectedValue)).ToList();
                }
                else
                {
                    var date = getDateToQuery();
                    games = vm.GetGames(Master.SeasonId, Convert.ToInt32(cmbDivisions.SelectedValue), date);
                }
                grdGames.DataSource = games.ToList<ScheduleGamesVM>();
                grdGames.DataBind();

            }
            catch (Exception ex)
            {
                lblError.Text = "LoadGames:" + ex.Message;

            }
        }
Exemplo n.º 5
0
 protected void grdGames_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     var gameObject = e.CommandArgument.ToString();
     var parameters = gameObject.Split(':');
     var scheduleNo = Convert.ToInt32(parameters[0]);
     var gameNo = Convert.ToInt32(parameters[1]);
     GameNo = gameNo;
     ScheduleGamesVM game;
     var vm = new ScheduleGamesVM();
     //get games
     if (e.CommandName == "SelectGame")
     {
         game = vm.GetGame(Convert.ToInt32(cmbDivisions.SelectedValue), gameNo, Master.SeasonId);
     }
     else
     {
         game = vm.GetPlayoffGame(Convert.ToInt32(cmbDivisions.SelectedValue), gameNo, Master.SeasonId);
     }
     LoadGameDetail(game);
 }
Exemplo n.º 6
0
        internal ScheduleGamesVM GetPlayoffGame(int divisionId, int gameNo, int seasonId)
        {
            using (var db = new CSBCDbContext())
            {
                var games = (
                    from g in db.SchedulePlayoffs
                    from l in db.ScheduleLocations
                    from d in db.Divisions
                    where g.DivisionId == divisionId && g.GameNumber == gameNo
                    where g.LocationNumber == l.LocationNumber
                    where g.DivisionId == d.DivisionID
                             select new
                             {
                                 g.ScheduleNumber,
                                 d.DivisionID,
                                 g.GameDate,
                                 g.GameTime,
                                 d.Div_Desc,
                                 g.LocationNumber,
                                 l.LocationName,
                                 g.GameNumber,
                                 g.HomeTeam,
                                 g.VisitingTeam,
                                 g.Descr

                             });
                var schedGames = new List<ScheduleGamesVM>();
                foreach (var g in games)
                {
                    var game = new ScheduleGamesVM
                    {
                        ScheduleNumber = g.ScheduleNumber,
                        DivisionId = g.DivisionID,
                        GameDate = (DateTime)g.GameDate,
                        GameTime = g.GameTime,
                        Division = g.Div_Desc,
                        LocationNumber = (int)g.LocationNumber,
                        LocationName = g.LocationName,
                        GameNumber = g.GameNumber,
                        HomeTeam = g.HomeTeam,
                        VisitorTeam = g.VisitingTeam,
                        Description = g.Descr
                    };
                    game.GameType = GameTypes.Playoff;
                    schedGames.Add(game);
                }
                var sgame = schedGames.FirstOrDefault<ScheduleGamesVM>();
                return sgame;
            }
        }
Exemplo n.º 7
0
        public List<ScheduleGamesVM> GetPlayoffGames(int divisionId)
        {
            using (var db = new CSBCDbContext())
            {
                //var rep = new SchedulePlayoffRepository(db);
                var games = (from g in db.SchedulePlayoffs
                             from l in db.ScheduleLocations
                             from d in db.Divisions
                             where g.DivisionId == divisionId
                             where g.LocationNumber == l.LocationNumber
                             where g.DivisionId == d.DivisionID
                             select new
                             {
                                 g.ScheduleNumber,
                                 d.DivisionID,
                                 g.GameDate,
                                 g.GameTime,
                                 d.Div_Desc,
                                 g.LocationNumber,
                                 l.LocationName,
                                 g.GameNumber,
                                 g.HomeTeam,
                                 g.VisitingTeam
                             });
                var schedGames = new List<ScheduleGamesVM>();
                foreach (var g in games)
                {
                    var game = new ScheduleGamesVM();

                    game.ScheduleNumber = g.ScheduleNumber;
                    game.DivisionId = g.DivisionID;
                    game.GameDate = (DateTime)g.GameDate;
                    game.GameTime = g.GameTime;
                    game.Division = g.Div_Desc;
                    game.LocationNumber = (int)g.LocationNumber;
                    game.LocationName = g.LocationName;
                    game.GameNumber = g.GameNumber;
                    game.HomeTeam = g.HomeTeam;
                    game.VisitorTeam = g.VisitingTeam;

                    game.GameType = GameTypes.Playoff;
                    schedGames.Add(game);
                }

                if (divisionId != 0)
                {
                    schedGames = schedGames.Where(g => g.DivisionId == divisionId)
                    .OrderBy(g => g.GameDate).ThenBy(g => g.GameTime).ThenBy(g => g.DivisionId).ToList<ScheduleGamesVM>();
                }
                return schedGames;
            }
        }
Exemplo n.º 8
0
        public List<ScheduleGamesVM> GetGames(int divisionId)
        {
            using (var db = new CSBCDbContext())
            {
                var rep = new ScheduleGameRepository(db);
                var games = (from g in db.ScheduleGames
                             from d in db.Divisions
                             from l in db.ScheduleLocations
                             where (g.DivisionId == divisionId)
                             where (d.DivisionID == divisionId)
                             where (g.LocationNumber == l.LocationNumber)
                             select new
                             {
                                 g.ScheduleNumber,
                                 g.DivisionId,
                                 g.GameDate,
                                 g.GameTime,
                                 d.Div_Desc,
                                 g.LocationNumber,
                                 l.LocationName,
                                 g.GameNumber,
                                 HomeTeamNo = db.Set<ScheduleDivTeam>().FirstOrDefault(t => t.TeamNumber == g.HomeTeamNumber).ScheduleTeamNumber,
                                 VisitorTeamNo = db.Set<ScheduleDivTeam>().FirstOrDefault(t => t.TeamNumber == g.VisitingTeamNumber).ScheduleTeamNumber
                             });
                var schedGames = new List<ScheduleGamesVM>();
                var teams = db.Set<Team>().Where(t => t.DivisionID == divisionId).ToList<Team>();
                foreach (var g in games)
                {
                    var game = new ScheduleGamesVM();

                    game.ScheduleNumber = g.ScheduleNumber;
                    game.DivisionId = (int)g.DivisionId;
                    game.GameDate = (DateTime)g.GameDate;
                    game.GameTime = g.GameTime;
                    game.Division = g.Div_Desc;
                    game.LocationNumber = (int)g.LocationNumber;
                    game.LocationName = g.LocationName;
                    game.GameNumber = g.GameNumber;
                    game.HomeTeam = GetTeamName(teams, g.HomeTeamNo);
                    game.VisitorTeam = GetTeamName(teams, g.VisitorTeamNo);
                    game.GameType = GameTypes.Regular;
                    schedGames.Add(game);
                }

                schedGames = schedGames.Where(g => g.DivisionId == divisionId)
                 .OrderBy(g => g.GameDate).ThenBy(g => g.GameTime).ThenBy(g => g.DivisionId).ToList<ScheduleGamesVM>();
                return schedGames;
            }
        }
Exemplo n.º 9
0
        public ScheduleGamesVM GetGame(int divisionId, int gameNo, int seasonId)
        {
            using (var db = new CSBCDbContext())
            {
                var games = (
                    from g in db.ScheduleGames
                    from d in db.Divisions
                    from l in db.ScheduleLocations
                    where (g.DivisionId == divisionId && g.GameNumber == gameNo)
                    where (d.DivisionID == divisionId)
                    where (g.LocationNumber == l.LocationNumber)
                    select new
                    {
                        g.ScheduleNumber,
                        d.DivisionID,
                        g.GameDate,
                        g.GameTime,
                        d.Div_Desc,
                        g.LocationNumber,
                        l.LocationName,
                        g.GameNumber,
                        HomeTeamNo = db.Set<ScheduleDivTeam>().FirstOrDefault(t => t.TeamNumber == g.HomeTeamNumber).ScheduleTeamNumber,
                        VisitorTeamNo = db.Set<ScheduleDivTeam>().FirstOrDefault(t => t.TeamNumber == g.VisitingTeamNumber).ScheduleTeamNumber
                    });
                var schedGames = new List<ScheduleGamesVM>();
                var teams = db.Set<Team>().Where(t => t.DivisionID == divisionId).ToList<Team>();
                foreach (var g in games)
                {
                    var game = new ScheduleGamesVM
                    {
                        ScheduleNumber = g.ScheduleNumber,
                        DivisionId = g.DivisionID,
                        GameDate = (DateTime)g.GameDate,
                        GameTime = g.GameTime,
                        Division = g.Div_Desc,
                        LocationNumber = (int)g.LocationNumber,
                        LocationName = g.LocationName,
                        GameNumber = g.GameNumber,
                        HomeTeamNo = g.HomeTeamNo,
                        VisitorTeamNo = g.VisitorTeamNo
                    };
                    game.HomeTeam = GetTeamName(teams, g.HomeTeamNo);
                    game.VisitorTeam = GetTeamName(teams, g.VisitorTeamNo);
                    game.GameType = GameTypes.Regular;
                    schedGames.Add(game);
                }
                //var game = db.ScheduleGames.FirstOrDefault(s => s.ScheduleNumber == scheduleNo && s.GameNumber == gameNo);
                var sgame = schedGames.FirstOrDefault<ScheduleGamesVM>();
                return sgame;

            }
        }