Ejemplo n.º 1
0
        public IHttpActionResult Get(string playerId)
        {
            Player player = _playerRepository.Get(playerId);

            if (player != null)
            {
                BasicPlayerDTO playerDto = new BasicPlayerDTO()
                {
                    id    = player._id,
                    name  = player.AccountName,
                    email = player.Email
                };
                return(Ok(playerDto));
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 2
0
        public IHttpActionResult Get(string playerName)
        {
            var    principal = Request.GetRequestContext().Principal as ClaimsPrincipal;
            Player player    = _playerRepository.GetByAccountName(playerName);

            if (player != null)
            {
                BasicPlayerDTO playerDto = new BasicPlayerDTO()
                {
                    _id   = player._id,
                    name  = player.AccountName,
                    email = player.Email
                };
                return(Ok(playerDto));
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 3
0
 public IHttpActionResult Post([FromBody] BasicPlayerDTO playerDTO)
 {
     if (ModelState.IsValid)
     {
         var player = _playerRepository.GetByEmail(playerDTO.email);
         if (player != null)
         {
             return(Conflict());
         }
         player = new Player()
         {
             AccountName = playerDTO.name,
             Email       = playerDTO.email
         };
         try
         {
             _playerRepository.Add(player);
             player = _playerRepository.GetByEmail(player.Email);
             if (player != null)
             {
                 return(Ok(new BasicPlayerDTO()
                 {
                     id = player._id,
                     name = player.AccountName,
                     email = player.Email
                 }));
             }
             // For some reason the player got added to the repository fine, but we were unable to get the player back from the repository.
             return(Ok());
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
     else
     {
         return(BadRequest(ModelState));
     }
 }
Ejemplo n.º 4
0
 // PUT: api/Player/5
 public void Put(string id, [FromBody] BasicPlayerDTO playerDTO)
 {
 }