public async Task <IActionResult> PostAsync([FromBody] Models.CreatePlayer player) { if (!TryValidateModel(player)) { return(BadRequest("Invalid player data.")); } var createdPlayer = _unitOfWork.Players.CreatePlayer(Mapper.Map(player)); await _unitOfWork.SaveAsync(); return(Created($"Player/{createdPlayer.Id}", createdPlayer)); }
public static DAL.Entities.Player Map(Models.CreatePlayer player) => new DAL.Entities.Player(0, player.Name);