示例#1
0
        private GameMatchModel GetUmpireDetail(GameMatchModel gameMatchModel)
        {
            GameMatchModel model = new GameMatchModel();
            Person         primaryUmpire;
            Person         secondaryUmpire;
            Person         reserveUmpire;

            if (gameMatchModel != null)
            {
                primaryUmpire   = _personSelect.GetPerson(gameMatchModel.primaryUmpireID ?? 0);
                secondaryUmpire = _personSelect.GetPerson(gameMatchModel.secondaryUmpireID ?? 0);
                reserveUmpire   = _personSelect.GetPerson(gameMatchModel.reserveUmpireID ?? 0);
                model           = gameMatchModel;

                if (primaryUmpire != null)
                {
                    model.primaryUmpire = (primaryUmpire.FirstName + " " + primaryUmpire.LastName).Trim();
                }
                if (secondaryUmpire != null)
                {
                    model.secondaryUmpire = (secondaryUmpire.FirstName + " " + secondaryUmpire.LastName).Trim();
                }
                if (reserveUmpire != null)
                {
                    model.secondaryUmpire = (reserveUmpire.FirstName + " " + reserveUmpire.LastName).Trim();
                }
            }
            return(model);
        }
示例#2
0
        public IList <TeamModel> GetTeamModeListByDivision(int divisionID)
        {
            IList <TeamModel> teamModelList = new List <TeamModel>();

            try
            {
                using (NetballEntities context = new NetballEntities())
                {
                    teamModelList = context.TeamPlayers
                                    .AsNoTracking()
                                    .Include(t => t.Team)
                                    .Include(t => t.Person)
                                    .Include(t => t.Team.Division)
                                    .Where(t => t.Team.DivisionID == divisionID)
                                    .Select(t => new TeamModel
                    {
                        teamID        = t.TeamID,
                        playerID      = t.PlayerID,
                        teamName      = t.Team.TeamName,
                        coachPersonID = t.Team.CoachID ?? 0,
                        divisionID    = t.Team.DivisionID ?? 0,
                        divisionName  = t.Team.Division.Division1,
                        captainID     = t.Team.CaptainID ?? 0,
                        playerName    = t.Person.FirstName + " " + t.Person.LastName
                    })
                                    .OrderBy(t => t.playerName)
                                    .ToList();
                }
                foreach (TeamModel teamModel in teamModelList)
                {
                    if (teamModel.coachPersonID != 0)
                    {
                        Person coach = new Person();
                        coach = _personSelect.GetPerson(teamModel.coachPersonID);
                        if (coach != null)
                        {
                            teamModel.coachName = coach.FirstName + " " + coach.LastName;
                        }
                    }
                    if (teamModel.captainID != 0)
                    {
                        Person captain = new Person();
                        captain = _personSelect.GetPerson(teamModel.captainID);
                        if (captain != null)
                        {
                            teamModel.captainName = captain.FirstName + " " + captain.LastName;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(teamModelList);
        }
示例#3
0
        public PlayerMatchModel GetPlayerMatchModel(int personID,
                                                    int?pageNumber,
                                                    int?pageSize)
        {
            PlayerMatchModel playerMatchModel = new PlayerMatchModel();
            Person           person;

            person = _personSelect.GetPerson(personID);

            if (person != null)
            {
                playerMatchModel.email              = person.Email;
                playerMatchModel.emergencyContact   = person.EmergencyContact;
                playerMatchModel.emergencyContactNo = person.EmergencyContactNo;
                playerMatchModel.firstName          = person.FirstName;
                playerMatchModel.lastName           = person.LastName;
                playerMatchModel.middleName         = person.MiddleName;
                playerMatchModel.mobile             = person.Mobile;
                playerMatchModel.personID           = person.PersonID;
                playerMatchModel.playerName         = (person.FirstName + " " + person.LastName).Trim();
                playerMatchModel.gameMatchModelList = GetGameMatchList(personID);
                playerMatchModel.gameMatchPagedList = GetGameMatchPagedList(personID, pageNumber, pageSize);
            }
            return(playerMatchModel);
        }
示例#4
0
        public void PlayerModelSave(PlayerModel playerModel,
                                    ref string message)
        {
            TeamPlayer teamPlayer;
            Person     person = new Person();

            if (_checkPlayerModelLogic.CheckPlayerModel(playerModel))
            {
                if (playerModel.personID > 0)
                {
                    _updatePlayerModelLogic.UpdatePlayerModel(playerModel);
                }
                else
                {
                    person = _personSelect.GetPerson(playerModel.firstName, playerModel.lastName);

                    if (person == null)
                    {
                        _insertPlayerModelLogic.InsertPlayerModel(ref playerModel);
                    }
                    else
                    {
                        playerModel.personID = person.PersonID;
                    }
                }

                if (_checkPlayerModelLogic.CheckPlayerModel(playerModel))
                {
                    teamPlayer = _teamPlayersSelect.GetTeamPlayer(playerModel.teamID, playerModel.personID);

                    if (teamPlayer == null)
                    {
                        teamPlayer          = new TeamPlayer();
                        teamPlayer.TeamID   = playerModel.teamID;
                        teamPlayer.PlayerID = playerModel.personID;
                    }

                    teamPlayer.CaptainInd = playerModel.captain;
                    _teamPlayersSaveLogic.TeamPlayerSave(teamPlayer, ref message);
                }
                else
                {
                    message = "<script>alert('Duplicate team player has been discovered. People must have unique names.');</script>";
                }
            }
        }
示例#5
0
        public CoachModel GetActiveCoachModel(int teamID)
        {
            CoachModel coachModel = new CoachModel();

            Database.Team team   = new Database.Team();
            Person        person = new Person();

            try
            {
                team = _teamSelectLogic.GetTeam(teamID);

                if (team != null)
                {
                    person = _personSelect.GetPerson(team.CoachID ?? 0);
                    coachModel.activeInd = true;
                    coachModel.captainID = team.CaptainID;

                    if (person != null)
                    {
                        coachModel.coachName          = (person.FirstName + " " + person.LastName).Trim();
                        coachModel.email              = person.Email;
                        coachModel.emergencyContact   = person.EmergencyContact;
                        coachModel.emergencyContactNo = person.EmergencyContactNo;
                        coachModel.firstName          = person.FirstName;
                        coachModel.lastName           = person.LastName;
                        coachModel.middleName         = person.MiddleName;
                        coachModel.mobile             = person.Mobile;
                    }
                    coachModel.divisionID = team.DivisionID;
                    coachModel.personID   = team.CoachID ?? 0;
                    coachModel.teamID     = teamID;
                    coachModel.teamName   = team.TeamName;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(coachModel);
        }
示例#6
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);
        }