public Coach Create(CreateCoachCommand command)
        {
            var coach = new Coach(command.IdUser, command.EvaluationTool, command.Speciality, command.Formation, command.CoachingProcess);

            _repository.Create(coach);

            if (Commit())
            {
                return(coach);
            }

            return(null);
        }
Example #2
0
 public Coach CreateCoach(Coach Coach)
 {
     try
     {
         if (_coachRepository.FindById(Coach.Id) != null)
         {
             return(null);
         }
         _coachRepository.Create(Coach);
         _coachRepository.Save();
         return(Coach);
     }
     catch (Exception ex)
     {
         _logger.LogWarning($"{ex.Message}\r\n{ex.StackTrace}");
         return(null);
     }
 }
        public async Task <ActionResult <Coach> > Post([FromBody] Coach coach)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                _repository.Create(coach);

                await _repository.SaveChangesAsync();

                return(Ok(coach));
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }