コード例 #1
0
        public ActionResult UpdatePlayer(int id, PlayerUpdateDto playerUpdateDto)
        {
            var playerModelFromRepo = _repository.GetPlayerById(id);

            if (playerModelFromRepo == null)
            {
                return(NotFound());
            }
            _mapper.Map(playerUpdateDto, playerModelFromRepo);

            _repository.UpdatePlayer(playerModelFromRepo);

            _repository.SaveChanges();

            return(NoContent());
        }
コード例 #2
0
        public async Task <string> UpdatePlayer(Guid playerId, PlayerViewModel updatedPlayer)
        {
            Guid   teamId         = _teamRepo.GetTeamIdByName(updatedPlayer.Team);
            Player playerToUpdate = ModelFactory.CreateDomainModel(updatedPlayer, teamId);
            await _repo.UpdatePlayer(playerId, playerToUpdate);

            return($"{updatedPlayer.Id} has been updated!");
        }
コード例 #3
0
 public async Task <Player> UpdatePlayer(Player player)
 {
     return(await repo.UpdatePlayer(player));
 }