Beispiel #1
0
        public virtual HttpResponseMessage SaveNewPlayer([FromBody] NewPlayerMessage newPlayerMessage, [FromUri] int gamingGroupId)
        {
            var requestedPlayer = new CreatePlayerRequest
            {
                Name               = newPlayerMessage.PlayerName,
                GamingGroupId      = newPlayerMessage.GamingGroupId,
                PlayerEmailAddress = newPlayerMessage.PlayerEmailAddress
            };

            Player newPlayer;

            try
            {
                newPlayer = _playerSaver.CreatePlayer(requestedPlayer, CurrentUser);
            }
            catch (PlayerAlreadyExistsException exception)
            {
                exception.ErrorSubCode = 1;
                throw;
            }
            catch (PlayerWithThisEmailAlreadyExistsException exception)
            {
                exception.ErrorSubCode = 2;
                throw;
            }

            var newlyCreatedPlayerMessage = new NewlyCreatedPlayerMessage
            {
                PlayerId      = newPlayer.Id,
                GamingGroupId = newPlayer.GamingGroupId,
                NemeStatsUrl  = AbsoluteUrlBuilder.GetPlayerDetailsUrl(newPlayer.Id)
            };

            return(Request.CreateResponse(HttpStatusCode.OK, newlyCreatedPlayerMessage));
        }
Beispiel #2
0
        public virtual HttpResponseMessage SaveNewPlayer([FromBody] NewPlayerMessage newPlayerMessage, [FromUri] int gamingGroupId)
        {
            var requestedPlayer = new Player
            {
                Name = newPlayerMessage.PlayerName
            };

            var actualNewlyCreatedPlayer = playerSaver.Save(requestedPlayer, CurrentUser);

            var newlyCreatedPlayerMessage = new NewlyCreatedPlayerMessage
            {
                PlayerId = actualNewlyCreatedPlayer.Id
            };

            return(Request.CreateResponse(HttpStatusCode.OK, newlyCreatedPlayerMessage));
        }