public async Task <ActionResult <Stadium> > PostNewStadium(StadiumCommand command) { try { var addedStadiumClub = command.ClubName; var newStadium = _mapper.Map <Stadium>(command); await _repository.PostNewStadium(addedStadiumClub, newStadium); _logger.LogInformation($"Stadium has been added."); return(Ok()); } catch (System.Exception ext) { _logger.LogError(ext, "Stadium hasn't been added."); // TODO return error object with proper error code. return(BadRequest()); } }
public async Task <ActionResult <Stadium> > PutExistingStadium(string stadiumName, StadiumCommand command) { try { var stadiumClub = command.ClubName; var updatedStadium = _mapper.Map <Stadium>(command); await _repository.PutExistingStadium(stadiumName, stadiumClub, updatedStadium); _logger.LogInformation($"Stadium has been updated."); return(Ok()); } catch (System.Exception ext) { _logger.LogError(ext, "Stadium hasn't been updated."); // TODO return error object with proper error code. return(BadRequest()); } }