Exemplo n.º 1
0
 private TeamGameStatistic FetchGameStatsByTeam(Team team, Game game, Context context)
 {
     var query = (from tgs in context.TeamGameStatistics
                  where (team.RefNum == tgs.TeamRefNum) && (game.RefNum == tgs.GameRefNum)
                  select tgs).Single();
     return query;
 }
 private IEnumerable<Team> FetchTeamsByConference(Conference conference, Context context)
 {
     var query = (from teams in context.Teams
                  where teams.ConfRefNum == conference.RefNum
                  select teams).ToList();
     return query;
 }
Exemplo n.º 3
0
        //============ Constructors =================//

        public GameService(int id)
        {
            _context = new Context();
            _id = id;
            _gameStat = GameStatistic(_id, _context);
            _game = FetchGameByGameStatistic(_gameStat);
        }
Exemplo n.º 4
0
        //public IEnumerable<PlayerRecord> FetchPlayerRecordsByPlayers()
        //{
        //    IEnumerable<Player> TeamPlayers = FetchPlayersByTeam();
        //    return FetchPlayerRecordsByPlayers(TeamPlayers);
        //}

        //public IEnumerable<TeamRecord> FetchTeamRecordsByTeam()
        //{
        //    return FetchTeamRecordsByTeam(_team, _context);
        //}


        //============= Private Methods =============//

        private Team FetchTeamById(int id, Context context)
        {
            var query = (from team in context.Teams
                         where team.Id == id
                         select team).SingleOrDefault();
            return query;
        }
Exemplo n.º 5
0
 private Team FetchByRefNum(string refNum, Context context)
 {
     Team query = (from team in context.Teams
                   where team.RefNum == refNum
                   select team).Single();
     return query;
 }
Exemplo n.º 6
0
 private Team FetchTeamByPlayer(Player player, Context context)
 {
     var query = (from team in context.Teams
                  where team.RefNum == player.TeamRefNum
                  select team).SingleOrDefault();
     return query;
 }
Exemplo n.º 7
0
 //============== Constructors =============//
 public TeamService(int id)
 {
     _id = id;
     _context = new Context();
     _team = FetchTeamById(_id, _context);
     
 }
Exemplo n.º 8
0
 private IEnumerable<PlayerRecord> FetchRecordsByPlayer(Player player, Context context)
 {
     var query = (from record in context.PlayerRecords
                  where record.PlayerRefNum == player.RefNum
                  select record).ToList();
     return query;
 }
Exemplo n.º 9
0
 private IEnumerable<Player> FetchPlayersBySearch(string searchValue, Context context)
 {
     var query = (from player in context.Players
                  where player.FirstName.Contains(searchValue) || player.LastName.Contains(searchValue)
                  select player).ToList();
     return query;
 }
Exemplo n.º 10
0
 private Stadium FetchStadiumByGame(Game game, Context context)
 {
     var query = (from stadium in context.Stadiums
                  where stadium.RefNum == game.StadiumRefNum
                  select stadium).SingleOrDefault();
     return query;
 }
Exemplo n.º 11
0
        private IEnumerable<Conference> FetchConferencesBySearch(string searchValue, Context context)
        {
            var query = (from conference in context.Conferences
                         where conference.Name.Contains(searchValue)
                         select conference).ToList();

            return query;
        }
Exemplo n.º 12
0
        private IEnumerable<Team> FetchTeamsBySearch(string searchValue, Context context)
        {
            var query = (from team in context.Teams
                         where team.Name.Contains(searchValue)
                         select team).ToList();

            return query;
        }
Exemplo n.º 13
0
 private Conference FetchConferenceByPlayer(Player player, Context context)
 {
     Team team = FetchTeamByPlayer(_player, _context);
     var query = (from conference in context.Conferences
                  where conference.RefNum == team.ConfRefNum
                  select conference).SingleOrDefault();
     return query;
 }
Exemplo n.º 14
0
        private Conference FetchConferenceByTeam(Team team, Context context)
        {
            string conferenceRefNum = team.ConfRefNum;

            Conference query = (from conference in context.Conferences
                                where conference.RefNum == conferenceRefNum
                                select conference).Single();
            return query;
        }
 private IEnumerable<TeamRecord> FetchRecordsByTeams(Conference conference, Context context, string gamePhase)
 {
     IEnumerable<Team> teamList = FetchTeamsByConference(conference, context);
     ICollection<TeamRecord> conferenceRecords = new List<TeamRecord>();
     foreach (Team team in teamList)
     {
         var recordList =  (from tr in context.TeamRecords
                           where tr.TeamRefNum == team.RefNum && tr.GamePhase == gamePhase
                           select tr).ToList();
         if (recordList != null)
         {
             foreach (var record in recordList)
             {
                 conferenceRecords.Add(record);
             }
         }
     }
     return conferenceRecords;
 }
Exemplo n.º 16
0
 private Team FetchTeamByGame(string homeOrVistior, Game game, Context context)
 {
     if (homeOrVistior == "home")
     {
         var query = (from team in context.Teams
                      where team.RefNum == game.HomeTeamRefNum
                      select team).Single();
         return query;
     }
     if (homeOrVistior == "visitor")
     {
         var query = (from team in context.Teams
                      where team.RefNum == game.VisitTeamRefNum
                      select team).Single();
         return query;
     }
     else
     {
         throw new ArgumentException("The method - FetchTeamByGame() in GameService.cs - requires the string to contain either home or visitor");
     }
 }
Exemplo n.º 17
0
 public SearchService(string searchValue)
 {
     _searchValue = searchValue;
     _context = new Context();
 }
Exemplo n.º 18
0
 private IEnumerable<Player> FetchPlayersByTeam(Team team, Context context)
 {
     var query = (from player in _context.Players
                  where player.TeamRefNum == _team.RefNum
                  select player).Distinct();
     return query;
 }
Exemplo n.º 19
0
        //private IEnumerable<PlayerRecord> FetchPlayerRecordsByPlayers(IEnumerable<Player> teamPlayers)
        //{
        //    ICollection<PlayerRecord> allPlayerRecords = new List<PlayerRecord>();
        //    foreach (Player player in teamPlayers)
        //    {
        //        var query = (from playerRecord in _context.PlayerRecords
        //                     where playerRecord.PlayerRefNum == player.RefNum
        //                     select playerRecord).Single();
        //        allPlayerRecords.Add(query);
        //    }
        //    return allPlayerRecords;
        //}

        //private IEnumerable<TeamRecord> FetchTeamRecordsByTeam(Team team, Context context)
        //{
        //    var query = (from teamRecord in context.TeamRecords
        //                 where teamRecord.TeamRefNum == team.RefNum
        //                 select teamRecord);
        //    return query;
        //}

        private IEnumerable<ICollection<string>> FetchGameInformationByTeam(Team team, Context context)
        {
            var Games = (from game in _context.Games
                         where game.HomeTeamRefNum == _team.RefNum || game.VisitTeamRefNum == _team.RefNum
                         select game).Distinct();

            ICollection<List<string>> gameDetail = new List<List<string>>();
            foreach (Game game in Games)
            {
                Team homeTeam = FetchByRefNum(game.HomeTeamRefNum, _context);
                Team visitTeam = FetchByRefNum(game.VisitTeamRefNum, _context);
                Stadium stadium = FetchStadiumByGame(game, _context);
                var gameInformation = new List<string>();
                gameInformation.Add(game.Date.ToString("mm/dd/yyyy"));
                gameInformation.Add(homeTeam.Name + " vs. " + visitTeam.Name + " at " + stadium.Name + " in " + stadium.City + ", " + stadium.State);
                gameInformation.Add(game.Id.ToString());
                gameDetail.Add(gameInformation);
            }
            return gameDetail;
        }
Exemplo n.º 20
0
 private Player Player(int id, Context context)
 {
     var player = context.Players.Find(id);
     return player;
 }
Exemplo n.º 21
0
 public PlayerService(int id)
 {
     _id = id;
     _context = new Context();
     _player = Player();
 }
 //============== Private Methods =============//
 private Conference Conference(Context context, int id)
 {
     var conference = context.Conferences.Find(id);
     return conference;
 }
 //============== Constructors =============//
 public ConferenceService(int id)
 {
     _id = id;
     _context = new Context();
     _conference = Conference(_context, _id);
 }
Exemplo n.º 24
0
 //=========== Private Methods ===============//
 private GameStatistic GameStatistic(int id, Context context)
 {
     var gameStat = context.GameStatistics.Find(id);
     return gameStat;
 }