Exemplo n.º 1
0
        public async Task <UserCalendarTrainingCreateDTO> CreateUserCalendarTraining(UserCalendarTrainingCreateDTO training)
        {
            if (training.StartDate > training.EndDate)
            {
                throw new Exception(DictionaryResources.InvalidDates);
            }
            var mappedTraining   = _mapper.Map <UserCalendarTraining>(training);
            var returnedTraining = await _trainingRepository.CreateUserCalendarTraining(mappedTraining);

            return(_mapper.Map <UserCalendarTrainingCreateDTO>(returnedTraining));
        }
        public async Task <ActionResult <UserCalendarTrainingCreateDTO> > CreateUserCalendarTraining([FromBody] UserCalendarTrainingCreateDTO training)
        {
            try
            {
                var returnedTraining = await _trainingService.CreateUserCalendarTraining(training);

                return(Ok(returnedTraining));
            }
            catch (Exception exception)
            {
                return(BadRequest(exception.Message));
            }
        }