Exemplo n.º 1
0
        private GameMatchModel GetTeamDetails(GameMatchModel gameMatchModel,
                                              int playerID)
        {
            GameMatchModel   model        = gameMatchModel;
            IList <GameTeam> gameTeamList = new List <GameTeam>();
            TeamPlayer       teamPlayer   = null;
            int    row = 1;
            int    gameTeamID;
            string teamName;
            int    teamScore;

            gameTeamList = _gameTeamSelect.GetGameTeamList(gameMatchModel.gameID);

            foreach (GameTeam gameTeam in gameTeamList)
            {
                if (row == 1)
                {
                    model.gameTeamID1 = gameTeam.TeamID;
                    model.teamName1   = gameTeam.Team.TeamName;
                    model.teamScore1  = gameTeam.FinalScore ?? 0;
                }
                else if (row == 2)
                {
                    model.gameTeamID2 = gameTeam.TeamID;
                    model.teamName2   = gameTeam.Team.TeamName;
                    model.teamScore2  = gameTeam.FinalScore ?? 0;
                }
                row++;
            }
            row = 1;
            foreach (GameTeam gameTeam in gameTeamList)
            {
                // Only perform for even number rows because gameTeamList contains both teams (with the same GameID).
                // So only do the swap on the second row if required.
                if (row % 2 == 0)
                {
                    teamPlayer = _teamPlayersSelect.GetTeamPlayer(gameTeam.TeamID, playerID);

                    // swap team 1 with team 2 so home team is always the current player ID
                    if (teamPlayer != null)
                    {
                        gameTeamID = model.gameTeamID1;
                        teamName   = model.teamName1;
                        teamScore  = model.teamScore1;

                        model.gameTeamID1 = model.gameTeamID2;
                        model.teamName1   = model.teamName2;
                        model.teamScore1  = model.teamScore2;
                        model.gameTeamID2 = gameTeamID;
                        model.teamName2   = teamName;
                        model.teamScore2  = teamScore;
                    }
                }
                row++;
            }
            return(model);
        }
Exemplo n.º 2
0
        public IList <GameModel> GetGameModelListByTeam(int teamID)
        {
            IList <GameModel> gameModelList  = new List <GameModel>();
            IList <GameModel> gameModelList2 = new List <GameModel>();
            IList <GameTeam>  gameTeamList   = new List <GameTeam>();

            using (NetballEntities context = new NetballEntities())
            {
                gameModelList = context.GameTeams
                                .AsNoTracking()
                                .Include(g => g.Team)
                                .Include(g => g.Game)
                                .Include(g => g.Game.Court)
                                .Include(g => g.Game.Division)
                                .Include(g => g.Game.Person)
                                .Include(g => g.Game.Person1)
                                .Include(g => g.Game.Person2)
                                .Include(g => g.Game.Person3)
                                .Include(g => g.Game.Person4)
                                .Include(g => g.Game.Person5)
                                .Include(g => g.Game.Person6)
                                .Include(g => g.Game.Division)
                                .Where(g => g.TeamID == teamID)
                                .Select(g => new GameModel
                {
                    gameID            = g.GameID,
                    courtID           = g.Game.CourtID,
                    courtName         = g.Game.Court.Court1,
                    tournamentID      = g.Game.TournamentID,
                    tournamentName    = g.Game.Tournament.Tournament1,
                    matchNo           = g.Game.MatchNo,
                    venue             = g.Game.Venue,
                    datePlayed        = g.Game.DatePlayed,
                    primaryUmpireID   = g.Game.PrimaryUmpireID,
                    primaryUmpire     = g.Game.Person.FirstName + " " + g.Game.Person.LastName,
                    secondaryUmpireID = g.Game.SecondaryUmpireID,
                    secondaryUmpire   = g.Game.Person1.FirstName + " " + g.Game.Person1.LastName,
                    reserveUmpireID   = g.Game.ReserveUmpireID,
                    reserveUmpire     = g.Game.Person2.FirstName + " " + g.Game.Person2.LastName,
                    startTime         = g.Game.StartTime,
                    fullTime          = g.Game.FullTime,
                    extraTimeEnd      = g.Game.ExtraTimeEnd,
                    scorer1ID         = g.Game.Scorer1ID,
                    scorer1           = g.Game.Person3.FirstName + " " + g.Game.Person3.LastName,
                    scorer2ID         = g.Game.Scorer2ID,
                    scorer2           = g.Game.Person4.FirstName + " " + g.Game.Person4.LastName,
                    timeKeeper1ID     = g.Game.TimeKeeper1ID,
                    timeKeeper1       = g.Game.Person5.FirstName + " " + g.Game.Person5.LastName,
                    timeKeeper2ID     = g.Game.TimeKeeper2ID,
                    timeKeeper2       = g.Game.Person6.FirstName + " " + g.Game.Person6.LastName,
                    divisionID        = g.Game.DivisionID,
                    division          = g.Game.Division.Division1
                })
                                .ToList();
            }
            if (gameModelList != null && gameModelList.Count > 0)
            {
                foreach (GameModel gameModel in gameModelList)
                {
                    int gameID = gameModel.gameID;
                    gameTeamList = new List <GameTeam>();
                    gameTeamList = _gameTeamSelect.GetGameTeamList(gameID);

                    if (gameTeamList.Count == 2)
                    {
                        gameModel.gameTeam1ID = gameTeamList[0].TeamID;
                        gameModel.team1Name   = gameTeamList[0].Team.TeamName;
                        gameModel.gameTeam2ID = gameTeamList[1].TeamID;
                        gameModel.team2Name   = gameTeamList[1].Team.TeamName;
                    }
                    gameModelList2.Add(gameModel);
                }
            }
            return(gameModelList2);
        }
Exemplo n.º 3
0
        public GameModel GetGameModelDetail(GameModel gameModel)
        {
            IList <GameTeam> gameTeamList = null;
            int         row         = 0;
            int?        team1ID     = null;
            int?        team2ID     = null;
            int?        finalScore1 = null;
            int?        finalScore2 = null;
            string      teamName1   = null;
            string      teamName2   = null;
            int?        coach1ID    = null;
            int?        coach2ID    = null;
            int         gameTeam1ID = 0;
            int         gameTeam2ID = 0;
            PlayerModel playerModel;

            try
            {
                gameTeamList = _gameTeamSelect.GetGameTeamList(gameModel.gameID);

                if (gameModel.primaryUmpireID != null)
                {
                    Person person = _personSelect.GetPerson(gameModel.primaryUmpireID ?? 0);
                    gameModel.primaryUmpire = person.FirstName + " " + person.LastName;
                }
                if (gameModel.secondaryUmpireID != null)
                {
                    Person person = _personSelect.GetPerson(gameModel.secondaryUmpireID ?? 0);
                    gameModel.secondaryUmpire = person.FirstName + " " + person.LastName;
                }
                if (gameModel.reserveUmpire != null)
                {
                    Person person = _personSelect.GetPerson(gameModel.reserveUmpireID ?? 0);
                    gameModel.reserveUmpire = person.FirstName + " " + person.LastName;
                }
                if (gameModel.scorer1ID != null)
                {
                    Person person = _personSelect.GetPerson(gameModel.scorer1ID ?? 0);
                    gameModel.scorer1 = person.FirstName + " " + person.LastName;
                }
                if (gameModel.scorer2ID != null)
                {
                    Person person = _personSelect.GetPerson(gameModel.scorer2ID ?? 0);
                    gameModel.scorer2 = person.FirstName + " " + person.LastName;
                }
                if (gameModel.timeKeeper1ID != null)
                {
                    Person person = _personSelect.GetPerson(gameModel.timeKeeper1ID ?? 0);
                    gameModel.scorer1 = person.FirstName + " " + person.LastName;
                }
                if (gameModel.timeKeeper2ID != null)
                {
                    Person person = _personSelect.GetPerson(gameModel.timeKeeper2ID ?? 0);
                    gameModel.scorer1 = person.FirstName + " " + person.LastName;
                }

                if (gameTeamList != null)
                {
                    foreach (GameTeam gameTeam in gameTeamList)
                    {
                        ++row;

                        if (row == 1)
                        {
                            team1ID     = gameTeam.TeamID;
                            teamName1   = gameTeam.Team.TeamName;
                            finalScore1 = gameTeam.FinalScore;
                            coach1ID    = gameTeam.CoachID;
                            gameTeam1ID = gameTeam.GameTeamID;
                        }
                        else
                        {
                            team2ID     = gameTeam.TeamID;
                            teamName2   = gameTeam.Team.TeamName;
                            finalScore2 = gameTeam.FinalScore;
                            coach2ID    = gameTeam.CoachID;
                            gameTeam2ID = gameTeam.GameTeamID;
                        }
                        gameModel.team1ID         = team1ID ?? 0;
                        gameModel.team1Name       = teamName1;
                        gameModel.team1ScoreFinal = finalScore1 ?? 0;
                        gameModel.coach1ID        = coach1ID;
                        gameModel.gameTeam1ID     = gameTeam1ID;
                        gameModel.team2ID         = team2ID ?? 0;
                        gameModel.team2Name       = teamName2;
                        gameModel.team2ScoreFinal = finalScore2 ?? 0;
                        gameModel.coach2ID        = coach2ID;
                        gameModel.gameTeam2ID     = gameTeam2ID;
                    }

                    playerModel = _captainSelect.GetCaptain(gameModel.team1ID);
                    if (playerModel != null)
                    {
                        gameModel.captain1ID = playerModel.personID;
                        gameModel.captain1   = playerModel.playerName;
                    }

                    playerModel = _captainSelect.GetCaptain(gameModel.team2ID);
                    if (playerModel != null)
                    {
                        gameModel.captain2ID = playerModel.personID;
                        gameModel.captain2   = playerModel.playerName;
                    }

                    if (gameModel.coach1ID != null)
                    {
                        Person person = _personSelect.GetPerson(gameModel.coach1ID ?? 0);
                        gameModel.coach1 = person.FirstName + " " + person.LastName;
                    }
                    if (gameModel.coach2ID != null)
                    {
                        Person person = _personSelect.GetPerson(gameModel.coach2ID ?? 0);
                        gameModel.coach2 = person.FirstName + " " + person.LastName;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(gameModel);
        }
Exemplo n.º 4
0
        public IList <GameModel> GetGameModelList()
        {
            IList <GameModel> gameModelList  = new List <GameModel>();
            IList <GameModel> gameModelList2 = new List <GameModel>();
            IList <GameTeam>  gameTeamList;

            try
            {
                using (NetballEntities context = new NetballEntities())
                {
                    gameModelList = context.Games
                                    .AsNoTracking()
                                    .Include(g => g.Court)
                                    .Include(g => g.Division)
                                    .Include(g => g.GameTeams)
                                    .Include(g => g.Tournament)
                                    .Select(g => new GameModel
                    {
                        gameID            = g.GameID,
                        courtID           = g.CourtID,
                        courtName         = g.Court.Court1,
                        tournamentID      = g.TournamentID,
                        tournamentName    = g.Tournament.Tournament1,
                        matchNo           = g.MatchNo,
                        venue             = g.Venue,
                        datePlayed        = g.DatePlayed,
                        primaryUmpireID   = g.PrimaryUmpireID,
                        secondaryUmpireID = g.SecondaryUmpireID,
                        reserveUmpireID   = g.ReserveUmpireID,
                        startTime         = g.StartTime,
                        fullTime          = g.FullTime,
                        extraTimeEnd      = g.ExtraTimeEnd,
                        scorer1ID         = g.Scorer1ID,
                        scorer2ID         = g.Scorer2ID,
                        timeKeeper1ID     = g.TimeKeeper1ID,
                        timeKeeper2ID     = g.TimeKeeper2ID,
                        divisionID        = g.DivisionID,
                        division          = g.Division.Division1
                    })
                                    .ToList();
                }
                if (gameModelList != null && gameModelList.Count > 0)
                {
                    foreach (GameModel gameModel in gameModelList)
                    {
                        int gameID = gameModel.gameID;
                        gameTeamList = new List <GameTeam>();
                        gameTeamList = _gameTeamSelect.GetGameTeamList(gameID);

                        if (gameTeamList.Count == 2)
                        {
                            gameModel.gameTeam1ID = gameTeamList[0].TeamID;
                            gameModel.team1Name   = gameTeamList[0].Team.TeamName;
                            gameModel.gameTeam2ID = gameTeamList[1].TeamID;
                            gameModel.team2Name   = gameTeamList[1].Team.TeamName;
                        }
                        gameModelList2.Add(gameModel);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(gameModelList2);
        }