Example #1
0
        public ActionResult <Response> SetNotificationsRead(ReadNotificationsRequest jsonNotificationIDs)
        {
            try
            {
                //Call the data access layer to update the notification records
                Response response = new PlayerDAL().SetNotificationsRead(jsonNotificationIDs);

                //If the response was successful update the client's notifications list
                if (response.IsSuccessful())
                {
                    new HubInterface(_hubContext).UpdateNotificationsRead(Convert.ToInt32(jsonNotificationIDs.PlayerID));
                }

                return(response);
            }
            //Catch any error associated with invalid model data
            catch (InvalidModelException e)
            {
                return(new Response(e.Msg, e.Code));
            }
            //Catch any unhandled / unexpected server errrors
            catch
            {
                return(StatusCode(500));
            }
        }
Example #2
0
        public ActionResult <Response> RemoveUnverifiedPlayer([FromForm] int playerID, [FromForm] int playerIDToRemove)
        {
            try
            {
                //Create the player submitting the request
                Player playerMakingRequest = new Player(playerID);

                //Create the player to remove
                Player playerToRemove = new Player(playerIDToRemove);

                //Remove the unverified player
                Response <Player> response = new PlayerDAL().RemoveUnverifiedPlayer(playerMakingRequest, playerToRemove);

                //if the response was successful call the hub interface to update the clients
                if (response.IsSuccessful())
                {
                    HubInterface hubInterface = new HubInterface(_hubContext);
                    hubInterface.UpdatePlayerLeftGame(response.Data);
                }

                return(new Response(response.ErrorMessage, response.ErrorCode));
            }
            //Catch any error associated with invalid model data
            catch (InvalidModelException e)
            {
                return(new Response <int>(e.Msg, e.Code));
            }
            //Catch any unhandled / unexpected server errrors
            catch
            {
                return(StatusCode(500));
            }
        }
Example #3
0
        public ActionResult <Response <Player> > UseAmmo([FromHeader] int playerID, [FromForm] double latitude, [FromForm] double longitude)
        {
            try
            {
                //Call the DataAccessLayer to get the player object from the DB
                Response <Player> getPlayerResponse = new PlayerDAL().GetPlayerByID(playerID);
                if (!getPlayerResponse.IsSuccessful())
                {
                    return(getPlayerResponse);
                }

                //If the player is a BR player process different, otherwise, process the CORE use ammo
                Player player = getPlayerResponse.Data;
                if (player.IsBRPlayer())
                {
                    return(BR_UseAmmoLogic(player, latitude, longitude));
                }

                //Otherwise, process the CORE use ammo logic
                else
                {
                    return(CORE_UseAmmoLogic(player));
                }
            }
            //Catch any error associated with invalid model data
            catch (InvalidModelException e)
            {
                return(new Response <Player>(e.Msg, e.Code));
            }
            //Catch any unhandled / unexpected server errrors
            catch
            {
                return(StatusCode(500));
            }
        }
Example #4
0
        public ActionResult <Response> ResendVerificationCode([FromHeader] int playerID)
        {
            try
            {
                Player player = new Player(playerID);

                //Generate a new code
                int newCode = Player.GenerateVerificationCode();

                //Call the Data Access Layer to update the verification code for the player and
                //get the contact information for the player
                Response <Player> response = new PlayerDAL().UpdateVerificationCode(player, newCode);

                //If the response is successful send the verification code to the player
                string msgTxt  = "Your CamTag verification code is: " + newCode;
                string subject = "CamTag Verification Code";
                if (response.IsSuccessful())
                {
                    response.Data.ReceiveMessage(msgTxt, subject);
                }

                return(new Response(response.ErrorMessage, response.ErrorCode));
            }
            //Catch any error associated with invalid model data
            catch (InvalidModelException e)
            {
                return(new Response(e.Msg, e.Code));
            }
            //Catch any unhandled / unexpected server errrors
            catch
            {
                return(StatusCode(500));
            }
        }
Example #5
0
        /// <summary>
        /// Method when a CamTag client disconnects from the application hub.
        /// Updates the clients connectionID = NULL and sets IsConnected = FALSE
        /// </summary>
        /// <param name="exception"></param>
        /// <returns></returns>
        public override Task OnDisconnectedAsync(Exception exception)
        {
            PlayerDAL playerDAL = new PlayerDAL();

            playerDAL.RemoveConnectionID(Context.ConnectionId);
            return(base.OnDisconnectedAsync(exception));
        }
Example #6
0
        /// <summary>
        /// Update a specific player that they have now been re-enabled and can take photos again.
        /// </summary>
        /// <param name="player">The player being re-enabled</param>
        public async void BR_UpdatePlayerReEnabled(Player player)
        {
            Console.WriteLine("HubInterface - BR_UpdatePlayerReEnabled");

            //Get the player from the database as this will run after a certain amount of time.
            //Get the most updated player information
            Response <Player> response = new PlayerDAL().GetPlayerByID(player.PlayerID);

            if (!response.IsSuccessful())
            {
                return;
            }

            player = response.Data;

            //Update the player if they are connected to the application
            if (player.IsConnected)
            {
                Console.WriteLine("Invoking UpdateNotifications and PlayerReEnabled on :" + player.Nickname);
                await _hubContext.Clients.Client(player.ConnectionID).SendAsync("UpdateNotifications");

                await _hubContext.Clients.Client(player.ConnectionID).SendAsync("PlayerReEnabled");
            }
            else
            {
                Console.WriteLine("Sending player re-enabled SMS or Email to :" + player.Nickname);
                player.ReceiveMessage("You have been re-enabled, go get em!", "You Have Been Re-enabled");
            }
        }
Example #7
0
        public ActionResult Index(PlayerViewModel playerViewModel)
        {
            PlayerDAL playerDAL = new PlayerDAL();

            List <Player> ListOfPlayers = playerDAL.GetAll();
            bool          IsExisting    = false;

            foreach (var player in ListOfPlayers)
            {
                if (playerViewModel.Nick == player.Nick)
                {
                    IsExisting = true;
                }
            }

            if (IsExisting)
            {
                Session["username"] = playerViewModel.Nick;
                //jesli istnieje to logujemy
            }
            else
            {
                playerDAL.Add(new Player {
                    Nick = playerViewModel.Nick
                });
                Session["username"] = playerViewModel.Nick;
                //dodajemy do sesji
            }

            return(View(playerViewModel));
        }
Example #8
0
        public void ListNotEmptyWhenGettingSkillers()
        {
            PlayerDAL     DAL     = new PlayerDAL();
            List <Player> results = DAL.GetPlayers();
            int           count   = (int)results.Count;

            Assert.NotEqual(0, count);
        }
Example #9
0
        public void AddPlayer(string name, string address, string phone, string email)
        {
            Player player = new Player {
                Name = name, Address = address, Phone = phone, Email = email
            };

            //next version, check for player's existence before adding
            //hello hello
            PlayerDAL.GetInstance().Add(player);
        }
Example #10
0
    void Start()
    {
        PlayerDAL dal = new PlayerDAL();

        playerStats = dal.LoadPlayerData();


        lbl_health.text       = "HP: " + playerStats.HP.ToString();
        lbl_level.text        = "Level:" + playerStats.Level.ToString();
        lbl_name.text         = getter.GetName();
        lbl_points.text       = "Points:" + getter.GetPoints().ToString();
        lbl_pointsGlobal.text = "Points:" + getter.GetPoints().ToString();
    }
        /// <summary>
        /// The code which will run in a new thread after the ammo replenish time has passed in order
        /// to increment the players ammo count.
        /// </summary>
        /// <param name="playerID">The ID of the player being updated.</param>
        /// <param name="hubInterface">The HubInterface used to to send live updates to users.</param>
        /// <param name="timeToWait">The number of milliseconds to sleep before the thread starts.</param>
        private static void Run_ReplenishAmmo(Player player, int timeToWait, HubInterface hubInterface)
        {
            Thread.Sleep(timeToWait);

            //Call the DataAccessLayer to increment the ammo count in the database
            PlayerDAL         playerDAL = new PlayerDAL();
            Response <Player> response  = playerDAL.ReplenishAmmo(player);

            if (response.IsSuccessful())
            {
                //As the ammo has replenished, send out a notification and update client.
                hubInterface.UpdateAmmoReplenished(response.Data);
            }
        }
Example #12
0
        public ActionResult <Response> Upload(PhotoUploadRequest request)
        {
            try
            {
                //Build the photo object
                Photo uploadedPhoto = new Photo(request.latitude, request.longitude, request.imgUrl, request.takenByID, request.photoOfID);

                //Get the player object from the database
                Response <Player> getPlayerResponse = new PlayerDAL().GetPlayerByID(uploadedPhoto.TakenByPlayerID);
                if (!getPlayerResponse.IsSuccessful())
                {
                    return(new Response(getPlayerResponse.ErrorMessage, getPlayerResponse.ErrorCode));
                }

                Response <Photo> response;

                //Call the BR Upload business logic if the player is a BR player
                if (getPlayerResponse.Data.IsBRPlayer())
                {
                    response = new PhotoDAL().SavePhoto(uploadedPhoto, true);
                }

                //Otherwise, call the CORE business logic
                else
                {
                    response = new PhotoDAL().SavePhoto(uploadedPhoto, false);
                }

                //If the response is successful we want to send live updates to clients and
                //email or text message notifications to not connected players
                if (response.IsSuccessful())
                {
                    HubInterface hubInterface = new HubInterface(_hubContext);
                    hubInterface.UpdatePhotoUploaded(response.Data);
                    ScheduledTasks.ScheduleCheckPhotoVotingCompleted(response.Data, hubInterface);
                }
                return(new Response(response.ErrorMessage, response.ErrorCode));
            }
            //Catch any error associated with invalid model data
            catch (InvalidModelException e)
            {
                return(new Response(e.Msg, e.Code));
            }
            //Catch any unhandled / unexpected server errrors
            catch
            {
                return(StatusCode(500));
            }
        }
Example #13
0
        /// <summary>
        /// Helper method for the UseAmmo request, processes the CORE gamemode business logic for using a players ammo.
        /// </summary>
        /// <param name="player">The player who is using the ammo</param>
        /// <returns>The updated player object outlining the new ammo count.</returns>
        private Response <Player> CORE_UseAmmoLogic(Player player)
        {
            Response <Player> response = new PlayerDAL().UseAmmo(player);

            //If the response was successful schedule code to run in order to replenish the players ammo
            if (response.IsSuccessful())
            {
                HubInterface hubInterface = new HubInterface(_hubContext);
                ScheduledTasks.ScheduleReplenishAmmo(response.Data, hubInterface);

                //Compress the player object before sending back over the network
                response.Data.Compress(true, true, true);
            }
            return(response);
        }
Example #14
0
 /// <summary>
 /// Method when a CamTag client connects to the application hub.
 /// Updates the clients connectionID and sets IsConnected = TRUE
 /// </summary>
 /// <returns></returns>
 public override Task OnConnectedAsync()
 {
     try
     {
         int    playerID = int.Parse(Context.GetHttpContext().Request.Query["playerID"]);
         Player player   = new Player(playerID);
         player.ConnectionID = Context.ConnectionId;
         PlayerDAL playerDAL = new PlayerDAL();
         playerDAL.UpdateConnectionID(player);
         return(base.OnConnectedAsync());
     }
     catch
     {
         return(null);
     }
 }
        /// <summary>
        /// The code which will run after the disabled time has elapsed and the player will be re-enabled.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="timeToWait"></param>
        /// <param name="hubInterface"></param>
        private static void Run_RenablePlayer(Player player, int timeToWait, HubInterface hubInterface)
        {
            //Wait for the specified time
            Thread.Sleep(timeToWait);

            //Renable the player
            Response <Player> response = new PlayerDAL().BR_DisableOrRenablePlayer(player, 0);

            if (!response.IsSuccessful())
            {
                return;
            }

            //Call the hub to send an update that the player has now been re-enabled
            hubInterface.BR_UpdatePlayerReEnabled(player);
        }
Example #16
0
        /// <summary>
        /// Helper method for the UseAmmo request, processes the BR gamemode businesss logic.
        /// Will confirm the player is within the playing radius, if not will disable the player.
        /// </summary>
        /// <param name="player">The player who is using the ammo</param>
        /// <param name="latitude">The latitude of the player.</param>
        /// <param name="longitude">The longitude of the player.</param>
        /// <returns></returns>
        private ActionResult <Response <Player> > BR_UseAmmoLogic(Player player, double latitude, double longitude)
        {
            //Decrement the players ammo
            Response <Player> response = new PlayerDAL().UseAmmo(player);

            if (!response.IsSuccessful())
            {
                return(response);
            }

            player = response.Data;
            HubInterface hubInterface = new HubInterface(_hubContext);

            //If the player is not within the zone disable the player
            if (!player.Game.IsInZone(latitude, longitude))
            {
                //Calculate the the number of minutes the player will be disabled for
                int totalMinutesDisabled      = player.Game.CalculateDisabledTime();
                int totalMillisecondsDisabled = totalMinutesDisabled * 60 * 1000;

                //Disable the player
                response = new PlayerDAL().BR_DisableOrRenablePlayer(player, totalMinutesDisabled);
                if (!response.IsSuccessful())
                {
                    return(response);
                }

                player = response.Data;

                //Call the hub to update the client that they are now disabled
                hubInterface.BR_UpdatePlayerDisabled(player, totalMinutesDisabled);

                //Schedule the player to be re-enabled
                ScheduledTasks.BR_SchedulePlayerReEnabled(player, hubInterface, totalMillisecondsDisabled);

                //Set the error code and message to indicate to the client that the player is now disabled.
                response.ErrorMessage = "Not inside the zone.";
                response.ErrorCode    = ErrorCodes.BR_NOTINZONE;
            }

            //Schedule the ammo to be replenished
            ScheduledTasks.ScheduleReplenishAmmo(player, hubInterface);

            //Compress the player object before sending back over the network
            response.Data.Compress(true, true, true);
            return(response);
        }
Example #17
0
        public ActionResult <Response> VoteOnPhoto([FromHeader] int playerID, [FromHeader] int voteID, [FromForm] string decision)
        {
            try
            {
                //Get the player object from the database
                Response <Player> getPlayerResponse = new PlayerDAL().GetPlayerByID(playerID);
                if (!getPlayerResponse.IsSuccessful())
                {
                    return(new Response(getPlayerResponse.ErrorMessage, getPlayerResponse.ErrorCode));
                }

                Vote            vote = new Vote(voteID, decision, playerID);
                Response <Vote> response;

                //Vote on the photo
                response = new PhotoDAL().VoteOnPhoto(vote, getPlayerResponse.Data.IsBRPlayer());
                if (response.IsSuccessful())
                {
                    //If the response's data is NULL that means the game is now completed for a BR game. Send live updates to complete the game
                    if (response.Data == null)
                    {
                        HubInterface hubInterface = new HubInterface(_hubContext);
                        hubInterface.UpdateGameCompleted(getPlayerResponse.Data.Game, false);
                    }

                    //If the Photo's voting has now been completed send the notifications / updates
                    else if (response.Data.Photo.IsVotingComplete)
                    {
                        HubInterface hubInterface = new HubInterface(_hubContext);
                        hubInterface.UpdatePhotoVotingCompleted(response.Data.Photo);
                    }
                }
                return(new Response(response.ErrorMessage, response.ErrorCode));
            }
            //Catch any error associated with invalid model data
            catch (InvalidModelException e)
            {
                return(new Response(e.Msg, e.Code));
            }
            //Catch any unhandled / unexpected server errrors
            catch
            {
                return(StatusCode(500));
            }
        }
Example #18
0
        /// <summary>
        /// Update a specific player for them to update their notification counter.
        /// </summary>
        /// <param name="playerID"></param>
        public async void UpdateNotificationsRead(int playerID)
        {
            Console.WriteLine("HubInterface - UpdateNotificationsRead");

            //Get the player from the database
            Response <Player> response = new PlayerDAL().GetPlayerByID(playerID);

            if (!response.IsSuccessful())
            {
                return;
            }

            //If the player is connected to the hub update the notifications list
            if (response.Data.IsConnected)
            {
                Console.WriteLine("Invoking UpdateNotifications on :" + response.Data.Nickname);
                await _hubContext.Clients.Client(response.Data.ConnectionID).SendAsync("UpdateNotifications");
            }
        }
Example #19
0
        public ActionResult <Response <Player> > JoinGame(JoinGameRequest request)
        {
            try
            {
                //Create the player object who will be joining the game
                Player playerToJoin = new Player(request.nickname, request.imgUrl, request.contact);
                Game   gameToJoin   = new Game(request.gameCode);

                //Generate a verification code
                int verificationCode = Player.GenerateVerificationCode();

                //Call the data access layer to add the player to the database
                Response <Player> response = new PlayerDAL().JoinGame(gameToJoin, playerToJoin, verificationCode);

                //If the response was successful, send the verification code to the player and update the lobby list
                if (response.IsSuccessful())
                {
                    string message = "Your CamTag verification code is: " + verificationCode;
                    string subject = "CamTag Verification Code";
                    response.Data.ReceiveMessage(message, subject);

                    //Call the hub interface to invoke client methods to update the clients that another player has joined
                    HubInterface hubInterface = new HubInterface(_hubContext);
                    hubInterface.UpdatePlayerJoinedGame(response.Data);

                    //Compress the player data before sending back over the network
                    response.Data.Compress(true, true, true);
                }
                return(response);
            }
            //Catch any error associated with invalid model data
            catch (InvalidModelException e)
            {
                return(new Response <Player>(e.Msg, e.Code));
            }
            //Catch any unhandled / unexpected server errrors
            catch
            {
                return(StatusCode(500));
            }
        }
Example #20
0
        public ActionResult <Response> VerifyPlayer([FromForm] string verificationCode, [FromHeader] int playerID)
        {
            try
            {
                Player playerToVerify = new Player(playerID);

                //Confirm the verification code is valid and return an error response if the verification code is invalid
                int code = Player.ValidateVerificationCode(verificationCode);
                if (code == -1)
                {
                    return(new Response("The verification code is invalid. Must be an INT between 10000 and 99999.", ErrorCodes.DATA_INVALID));
                }

                //Call the data access layer to confirm the verification code is correct.
                Response <Player> response = new PlayerDAL().ValidateVerificationCode(code, playerToVerify);

                //If the player was successfully verified, updated all the clients about a joined player.
                if (response.IsSuccessful())
                {
                    HubInterface hubInterface = new HubInterface(_hubContext);
                    hubInterface.UpdatePlayerJoinedGame(response.Data);
                }

                return(response);
            }
            //Catch any error associated with invalid model data
            catch (InvalidModelException e)
            {
                return(new Response(e.Msg, e.Code));
            }
            //Catch any unhandled / unexpected server errrors
            catch
            {
                return(StatusCode(500));
            }
        }
Example #21
0
        public ActionResult <Response <Player> > CreateGame(CreateGameRequest request)
        {
            //Create the player object from the request and validate
            try
            {
                //Create the host player who is joining, will perform data valiation inside Player Class
                Player hostPlayer = new Player(request.nickname, request.imgUrl, request.contact);
                hostPlayer.IsHost = true;

                GameDAL           gameDAL       = new GameDAL();
                Response <Game>   createdGame   = null;
                Response <Player> createdPlayer = null;

                //Generate a game code and create a new game in the database
                //Creating the game inside a while loop because there is a chance that the gamecode could be duplicated
                bool doRun = true;
                while (doRun)
                {
                    Game newGame = null;

                    newGame = new Game(Game.GenerateGameCode(),
                                       request.timeLimit,
                                       request.ammoLimit,
                                       request.startDelay,
                                       request.replenishAmmoDelay,
                                       request.gameMode,
                                       request.isJoinableAtAnytime,
                                       request.Latitude,
                                       request.Longitude,
                                       request.Radius);

                    createdGame = gameDAL.CreateGame(newGame);

                    //If the response is successful the game was successfully created
                    if (createdGame.IsSuccessful())
                    {
                        doRun = false;
                    }

                    //If the response contains an error code of ITEMALREADYEXISTS then the game code is not unique,
                    //Want to run again and generate a new code
                    else if (createdGame.ErrorCode == ErrorCodes.ITEM_ALREADY_EXISTS)
                    {
                        doRun = true;
                    }

                    //If the response contains any other error code we do not want to run again because an un expected
                    //error occurred and we want to return the error response.
                    else
                    {
                        doRun = false;
                    }
                }

                //If the create game failed, return the error message and code from that response
                if (!createdGame.IsSuccessful())
                {
                    return(new Response <Player>(createdGame.ErrorMessage, createdGame.ErrorCode));
                }

                //Call the player data access layer to join the player to that game
                int verificationCode = Player.GenerateVerificationCode();
                createdPlayer = new PlayerDAL().JoinGame(createdGame.Data, hostPlayer, verificationCode);

                //If the response was successful, send the verification code to the player
                string message = "Your CamTag verification code is: " + verificationCode;
                string subject = "CamTag Verification Code";
                if (createdPlayer.IsSuccessful())
                {
                    createdPlayer.Data.ReceiveMessage(message, subject);
                }

                //Otherwise, the host player failed to join the game deleted the created game
                else
                {
                    gameDAL.DeactivateGameAfterHostJoinError(createdGame.Data);
                }

                //Compress the player object so no photo data is sent back to the client to speed up request times
                createdPlayer.Data.Compress(true, true, true);

                return(createdPlayer);
            }
            //Catch any error associated with invalid model data
            catch (InvalidModelException e)
            {
                return(new Response <Player>(e.Msg, e.Code));
            }
            //Catch any unhandled / unexpected server errrors
            catch
            {
                return(StatusCode(500));
            }
        }
Example #22
0
 public Player GetPlayerByName(string name)
 {
     return(PlayerDAL.GetInstance().GetByName(name));
 }
Example #23
0
 public List <Player> GetAllPlayers()
 {
     return(PlayerDAL.GetInstance().GetAllPlayers());
 }
Example #24
0
        public ActionResult <Response> LeaveGame([FromHeader] int playerID)
        {
            try
            {
                Player player = new Player(playerID);

                //Get the player who is leaving the game
                PlayerDAL         playerDAL         = new PlayerDAL();
                Response <Player> getPlayerResponse = playerDAL.GetPlayerByID(playerID);
                if (!getPlayerResponse.IsSuccessful())
                {
                    return(new Response(getPlayerResponse.ErrorMessage, getPlayerResponse.ErrorCode));
                }

                player = getPlayerResponse.Data;

                //Create the hub interface which will be used to send live updates to clients
                HubInterface hubInterface = new HubInterface(_hubContext);

                //If the player leaving the game is the host and the game is currently in the lobby kick all other players from the game
                //because only the host player can begin the game
                if (player.IsHost && player.Game.IsInLobby())
                {
                    Response endLobbyResponse = new GameDAL().EndLobby(player.Game);

                    //If successfully kicked all players from the game send live updates to clients that they have been removed from the lobby
                    if (endLobbyResponse.IsSuccessful())
                    {
                        hubInterface.UpdateLobbyEnded(player.Game);
                    }

                    //Return and leave the method because there is nothing else to process at this point
                    return(endLobbyResponse);
                }


                //Call the data access layer to remove the player from the game.
                bool isGameComplete   = false;
                bool isPhotosComplete = false;
                Response <List <Photo> > leaveGameResponse = playerDAL.LeaveGame(player, ref isGameComplete, ref isPhotosComplete);

                //Return the error response if an error occurred
                if (!leaveGameResponse.IsSuccessful())
                {
                    return(new Response(leaveGameResponse.ErrorMessage, leaveGameResponse.ErrorCode));
                }

                //Call the hub method to send out notifications to players that the game is now complete
                if (isGameComplete)
                {
                    hubInterface.UpdateGameCompleted(player.Game, true);
                }

                //Otherwise, if the photo list is not empty then photos have been completed and need to send out updates
                else if (isPhotosComplete)
                {
                    foreach (var photo in leaveGameResponse.Data)
                    {
                        hubInterface.UpdatePhotoVotingCompleted(photo);
                    }
                }

                //If the game is not completed send out the player left notification
                if (!isGameComplete)
                {
                    hubInterface.UpdatePlayerLeftGame(player);
                }

                return(new Response(leaveGameResponse.ErrorMessage, leaveGameResponse.ErrorCode));
            }
            //Catch any error associated with invalid model data
            catch (InvalidModelException e)
            {
                return(new Response(e.Msg, e.Code));
            }
            //Catch any unhandled / unexpected server errrors
            catch
            {
                return(StatusCode(500));
            }
        }
Example #25
0
        public ActionResult <Response <MapResponse> > GetMap([FromHeader] int playerID)
        {
            try
            {
                Player player = new Player(playerID);

                //Get the player from the database
                Response <Player> playerResponse = new PlayerDAL().GetPlayerByID(playerID);
                if (!playerResponse.IsSuccessful())
                {
                    return(new Response <MapResponse>(playerResponse.ErrorMessage, playerResponse.ErrorCode));
                }

                //Call the data access layer to get the last known locations
                Response <List <Photo> > getLastPhotoLocationsResponse = new PhotoDAL().GetLastKnownLocations(player);
                if (!getLastPhotoLocationsResponse.IsSuccessful())
                {
                    return(new Response <MapResponse>(getLastPhotoLocationsResponse.ErrorMessage, getLastPhotoLocationsResponse.ErrorCode));
                }

                //If the response was successful compress the photo to remove any unneccessary data needed for the map
                foreach (var photo in getLastPhotoLocationsResponse.Data)
                {
                    photo.CompressForMapRequest();
                }

                MapResponse map;

                //if the player is not a BR player return the list of photos
                if (!playerResponse.Data.IsBRPlayer())
                {
                    map = new MapResponse()
                    {
                        Photos    = getLastPhotoLocationsResponse.Data,
                        IsBR      = false,
                        Latitude  = 0,
                        Longitude = 0,
                        Radius    = 0
                    };
                }

                //otherwise, calculate the currenct radius
                else
                {
                    map = new MapResponse()
                    {
                        Photos    = getLastPhotoLocationsResponse.Data,
                        IsBR      = true,
                        Latitude  = playerResponse.Data.Game.Latitude,
                        Longitude = playerResponse.Data.Game.Longitude,
                        Radius    = playerResponse.Data.Game.CalculateRadius()
                    };
                }

                return(new Response <MapResponse>(map));
            }
            //Catch any error associated with invalid model data
            catch (InvalidModelException e)
            {
                return(new Response <MapResponse>(e.Msg, e.Code));
            }
            //Catch any unhandled / unexpected server errrors
            catch
            {
                return(StatusCode(500));
            }
        }