Exemplo n.º 1
0
 public static Player FromPlayerPost(PlayerPostRequest post)
 {
     return(new Player {
         Name = post.Name,
         Age = post.Age
     });
 }
        public Task <Player> Add(PlayerPostRequest post)
        {
            var player = Player.FromPlayerPost(post);

            Players.Add(player);
            return(Task.FromResult(player));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> Post([FromBody] PlayerPostRequest request,
                                              [FromServices] LinkGenerator linkGenerator)
        {
            var player = await _playersRepository.Add(request);

            var url = linkGenerator.GetPathByAction(HttpContext,
                                                    nameof(Get),
                                                    values: new { player.Id });

            return(Created(url, player));
        }