Esempio n. 1
0
        public static IYear ChooseYear(YearEnum year)
        {
            switch (year)
            {
            case YearEnum.Year1918_1919:
                return(new Year1918_1919());

            case YearEnum.Year1968_1970:
                return(new Year1968_1970());

            case YearEnum.Year2002_2003:
                return(new Year2002_2003());

            case YearEnum.Year2005_2014:
                return(new Year2005_2014());

            case YearEnum.Year2009_2010:
                return(new Year2009_2010());

            case YearEnum.Year2012_2015:
                return(new Year2012_2015());

            case YearEnum.Year2019_2020:
                return(new Year2019_2020());

            default:
                return(null);
            }
        }
Esempio n. 2
0
 public Semester(SemesterEnum i, YearEnum y)
 {
     semesterBox = new ListBox();
     semesterBox.AllowDrop = true;
     ID = i;
     year = y;
 }
Esempio n. 3
0
        private void addSemester(SemesterEnum id, YearEnum y)
        {
            Semester semester = new Semester(id,y);
            schedule.addSem(semester);

            semester.semesterBox.SetBounds(130*((int)id) + 75, 105*((int)y) + 60, 120, 95);
            this.Controls.Add(semester.semesterBox);
        }
Esempio n. 4
0
 private void yearComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try {
         // Get the selected year.
         YearEnum yearEnum = (YearEnum)this.yearComboBox.SelectedItem;
         this.selectedYear      = BadYearType.ChooseBadYear(yearEnum);
         this.selectedIterator  = this.selectedYear.CreateIterator();
         this.labelYear.Content = this.selectedYear.ToString();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 5
0
        public static IHorribleYear ChooseBadYear(YearEnum year)
        {
            switch (year)
            {
            case YearEnum.Year1942:
                return(new Year1942());

            case YearEnum.Year1968:
                return(new Year1968());

            case YearEnum.Year2016:
                return(new Year2016());

            default:
                return(null);
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Body10" /> class.
 /// </summary>
 /// <param name="day">day (required).</param>
 /// <param name="email">email (required).</param>
 /// <param name="month">month (required).</param>
 /// <param name="year">year (required).</param>
 public Body10(DayEnum day = default(DayEnum), string email = default(string), MonthEnum month = default(MonthEnum), YearEnum year = default(YearEnum))
 {
     // to ensure "day" is required (not null)
     if (day == null)
     {
         throw new InvalidDataException("day is a required property for Body10 and cannot be null");
     }
     else
     {
         this.Day = day;
     }
     // to ensure "email" is required (not null)
     if (email == null)
     {
         throw new InvalidDataException("email is a required property for Body10 and cannot be null");
     }
     else
     {
         this.Email = email;
     }
     // to ensure "month" is required (not null)
     if (month == null)
     {
         throw new InvalidDataException("month is a required property for Body10 and cannot be null");
     }
     else
     {
         this.Month = month;
     }
     // to ensure "year" is required (not null)
     if (year == null)
     {
         throw new InvalidDataException("year is a required property for Body10 and cannot be null");
     }
     else
     {
         this.Year = year;
     }
 }
Esempio n. 7
0
 public Student(string firstName, string lastName, int phone, int studentNumber, YearEnum yearAttend)
     : base(firstName, lastName, phone)
 {
     StudentNumber = StudentNumber;
     YearAttend    = yearAttend;
 }
Esempio n. 8
0
        public ActionResult TeamData(int teamId, YearEnum year)
        {
            IEnumerable<GameParticipant> gameParticipants;
            if (year == YearEnum.All)
            {
                var team = DbContext.Teams.SingleOrDefault(ty => ty.TeamId == teamId);
                if (team == null)
                {
                    return HttpNotFound();
                }

                gameParticipants = team.TeamYears.SelectMany(ty => ty.GameParticipants);
            }
            else
            {
                var teamYear = DbContext.TeamYears.SingleOrDefault(ty => ty.TeamId == teamId && ty.Year == (int)year);
                if (teamYear == null)
                {
                    return HttpNotFound();
                }

                gameParticipants = teamYear.GameParticipants;
            }

            var data = gameParticipants
                .SelectMany(gp => gp.StatLines)
                .GroupBy(sl => new {sl.PlayerId, sl.Player.FirstName, sl.Player.LastName})
                .Select(slg => new TeamPlayerStatisticsRowModel
                               {
                                   Year = year,
                                   Player = new StatisticsPlayerInfoModel
                                            {
                                                PlayerId = slg.Key.PlayerId,
                                                PlayerFirstName = slg.Key.FirstName,
                                                PlayerLastName = slg.Key.LastName
                                            },
                                   Games = slg.Count(),
                                   PlateAppearances = slg.Sum(sl => sl.StatPlateAppearances),
                                   AtBats = slg.Sum(sl => sl.StatAtBats),
                                   Hits = slg.Sum(sl => sl.StatHits),
                                   TotalBases = slg.Sum(sl => sl.StatTotalBases),
                                   Runs = slg.Sum(sl => sl.StatRuns),
                                   RunsBattedIn = slg.Sum(sl => sl.StatRunsBattedIn),
                                   Singles = slg.Sum(sl => sl.StatSingles),
                                   Doubles = slg.Sum(sl => sl.StatDoubles),
                                   Triples = slg.Sum(sl => sl.StatTriples),
                                   HomeRuns = slg.Sum(sl => sl.StatHomeRuns),
                                   Walks = slg.Sum(sl => sl.StatWalks),
                                   SacrificeFlies = slg.Sum(sl => sl.StatSacrificeFlies),
                                   Outs = slg.Sum(sl => sl.StatOuts),
                                   FieldersChoices = slg.Sum(sl => sl.StatFieldersChoices),
                                   ReachedByErrors = slg.Sum(sl => sl.StatReachedByErrors),
                                   Strikeouts = slg.Sum(sl => sl.StatStrikeouts)
                               });

            return Json(data);
        }
Esempio n. 9
0
        public ActionResult StatisticsForLeagueIndividual(YearEnum year = (YearEnum)Consts.CurrentYear)
        {
            var model = new LeagueStatisticsPageModel
            {
                Year = year
            };

            return View(model);
        }
Esempio n. 10
0
        public ActionResult StatisticsForTeam(int teamId, YearEnum year = (YearEnum)Consts.CurrentYear, string sort = null)
        {
            var teamYear = DbContext.TeamYears
                                    .OrderByDescending(ty => ty.Year)
                                    .FirstOrDefault(ty => ty.TeamId == teamId && (year == YearEnum.All || ty.Year == (int)year));
            if (teamYear == null)
            {
                return HttpNotFound();
            }

            var model = new TeamStatisticsPageModel
                        {
                            Year = year,
                            Team = new StatisticsTeamInfoModel
                                   {
                                       TeamId = teamYear.TeamId,
                                       TeamName = teamYear.FullName
                                   },
                            SortColumn = sort
                        };

            return View(model);
        }
Esempio n. 11
0
        public ActionResult PlayerData(int playerId, YearEnum year)
        {
            var player = DbContext.Players.FirstOrDefault(ty => ty.PlayerId == playerId);
            if (player == null)
            {
                return HttpNotFound();
            }

            var data = year == YearEnum.All
                           ? GetPlayerCareerData(player)
                           : GetPlayerSeasonData(player, (int)year);

            return Json(data);
        }
Esempio n. 12
0
        public ActionResult StatisticsForPlayer(int playerId, YearEnum year = (YearEnum)Consts.CurrentYear)
        {
            var player = DbContext.Players.FirstOrDefault(ty => ty.PlayerId == playerId);
            if (player == null)
            {
                return HttpNotFound();
            }

            var model = new PlayerStatisticsPageModel
                        {
                            Year = year,
                            Player = new StatisticsPlayerInfoModel
                                     {
                                         PlayerId = player.PlayerId,
                                         PlayerFirstName = player.FirstName,
                                         PlayerLastName = player.LastName
                                     }
                        };

            return View(model);
        }
Esempio n. 13
0
        public ActionResult LeagueTeamData(YearEnum year)
        {
            var statLines = DbContext.StatLines.AsQueryable();

            if (year != YearEnum.All)
            {
                statLines = statLines.Where(sl => sl.GameParticipant.Game.GameDate.Year == (int)year);
            }

            var data = statLines
                .GroupBy(sl => new
                               {
                                   TeamId = sl.GameParticipant.TeamYear.TeamId,
                                   TeamName = sl.GameParticipant.TeamYear.FullName,
                                   Games = sl.GameParticipant.TeamYear.GameParticipants.Count(gp => gp.StatLines.Any())
                               })
                .Select(slg => new LeagueTeamStatisticsRowModel
                               {
                                   Year = year,
                                   Team = new StatisticsTeamInfoModel
                                          {
                                              TeamId = slg.Key.TeamId,
                                              TeamName = slg.Key.TeamName
                                          },
                                   Games = slg.Key.Games,
                                   PlateAppearances = slg.Sum(sl => sl.StatPlateAppearances),
                                   AtBats = slg.Sum(sl => sl.StatAtBats),
                                   Hits = slg.Sum(sl => sl.StatHits),
                                   TotalBases = slg.Sum(sl => sl.StatTotalBases),
                                   Runs = slg.Sum(sl => sl.StatRuns),
                                   RunsBattedIn = slg.Sum(sl => sl.StatRunsBattedIn),
                                   Singles = slg.Sum(sl => sl.StatSingles),
                                   Doubles = slg.Sum(sl => sl.StatDoubles),
                                   Triples = slg.Sum(sl => sl.StatTriples),
                                   HomeRuns = slg.Sum(sl => sl.StatHomeRuns),
                                   Walks = slg.Sum(sl => sl.StatWalks),
                                   SacrificeFlies = slg.Sum(sl => sl.StatSacrificeFlies),
                                   Outs = slg.Sum(sl => sl.StatOuts),
                                   FieldersChoices = slg.Sum(sl => sl.StatFieldersChoices),
                                   ReachedByErrors = slg.Sum(sl => sl.StatReachedByErrors),
                                   Strikeouts = slg.Sum(sl => sl.StatStrikeouts)
                               });

            return Json(data);
        }
Esempio n. 14
0
        public ActionResult LeagueIndividualData(YearEnum year)
        {
            var statLines = DbContext.StatLines.AsQueryable();

            IQueryable<IGrouping<PlayerStatGroup, StatLine>> groupedStatLines;

            if (year != YearEnum.All)
            {
                groupedStatLines = statLines
                    .Where(sl => sl.GameParticipant.Game.GameDate.Year == (int)year)
                    .GroupBy(sl => new PlayerStatGroup
                                   {
                                       PlayerId = sl.PlayerId,
                                       PlayerFirstName = sl.Player.FirstName,
                                       PlayerLastName = sl.Player.LastName,
                                       TeamId = sl.GameParticipant.TeamYear.TeamId,
                                       TeamName = sl.GameParticipant.TeamYear.FullName
                                   });
            }
            else
            {
                groupedStatLines = statLines
                    .GroupBy(sl => new PlayerStatGroup
                                   {
                                       PlayerId = sl.PlayerId,
                                       PlayerFirstName = sl.Player.FirstName,
                                       PlayerLastName = sl.Player.LastName,
                                       TeamId = sl.Player.CurrentTeam.TeamYears.OrderByDescending(ty => ty.Year).FirstOrDefault().TeamId,
                                       TeamName = sl.Player.CurrentTeam.TeamYears.OrderByDescending(ty => ty.Year).FirstOrDefault().FullName
                                   });
            }

            var data = groupedStatLines
                .Select(slg => new LeagueIndividualStatisticsRowModel
                               {
                                   Year = year,
                                   Player = new StatisticsPlayerInfoModel
                                            {
                                                PlayerId = slg.Key.PlayerId,
                                                PlayerFirstName = slg.Key.PlayerFirstName,
                                                PlayerLastName = slg.Key.PlayerLastName
                                            },
                                   Team = new StatisticsTeamInfoModel
                                          {
                                              TeamId = slg.Key.TeamId,
                                              TeamName = slg.Key.TeamName
                                          },
                                   Games = slg.Count(),
                                   PlateAppearances = slg.Sum(sl => sl.StatPlateAppearances),
                                   AtBats = slg.Sum(sl => sl.StatAtBats),
                                   Hits = slg.Sum(sl => sl.StatHits),
                                   TotalBases = slg.Sum(sl => sl.StatTotalBases),
                                   Runs = slg.Sum(sl => sl.StatRuns),
                                   RunsBattedIn = slg.Sum(sl => sl.StatRunsBattedIn),
                                   Singles = slg.Sum(sl => sl.StatSingles),
                                   Doubles = slg.Sum(sl => sl.StatDoubles),
                                   Triples = slg.Sum(sl => sl.StatTriples),
                                   HomeRuns = slg.Sum(sl => sl.StatHomeRuns),
                                   Walks = slg.Sum(sl => sl.StatWalks),
                                   SacrificeFlies = slg.Sum(sl => sl.StatSacrificeFlies),
                                   Outs = slg.Sum(sl => sl.StatOuts),
                                   FieldersChoices = slg.Sum(sl => sl.StatFieldersChoices),
                                   ReachedByErrors = slg.Sum(sl => sl.StatReachedByErrors),
                                   Strikeouts = slg.Sum(sl => sl.StatStrikeouts)
                               });

            return Json(data);
        }