コード例 #1
0
        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());
            }
        }
コード例 #2
0
        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());
            }
        }