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()); }
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!"); }
public async Task <Player> UpdatePlayer(Player player) { return(await repo.UpdatePlayer(player)); }