public async Task <ActionResult <Coach> > PostNewCoach(CoachCommand command) { try { var addedCoachCurrentClub = command.CurrentClub; var newCoach = _mapper.Map <Coach>(command); await _repository.PostNewCoach(addedCoachCurrentClub, newCoach); _logger.LogInformation($"Coach has been added."); return(Ok()); } catch (System.Exception ext) { _logger.LogError(ext, "Coach hasn't been added."); // TODO return error object with proper error code. return(BadRequest()); } }
public async Task <ActionResult <Coach> > PutExistingCoach(string coachsurname, CoachCommand command) { try { var coachCurrentClub = command.CurrentClub; var updatedCoach = _mapper.Map <Coach>(command); await _repository.PutExistingCoach(coachsurname, coachCurrentClub, updatedCoach); _logger.LogInformation($"Coach has been updated."); return(Ok()); } catch (System.Exception ext) { _logger.LogError(ext, "Coach hasn't been updated."); // TODO return error object with proper error code. return(BadRequest()); } }