public IActionResult PostLesson([FromBody] PostLessonDTO body) { var newLesson = _mapper.Map <Lesson>(body); _uow.Repository <Lesson>().Add(newLesson); if (!_uow.Complete(1)) { return(StatusCode(StatusCodes.Status500InternalServerError)); } return(CreatedAtRoute("GetLesson", new { id = newLesson.Id }, _mapper.Map <SimpleLessonDTO>(newLesson))); }
public IActionResult PostLesson([FromBody] PostLessonDTO body) { try { var newLesson = _mapper.Map <Lesson>(body); _uow.LessonRepository.Create(newLesson); _uow.Complete(false); return(CreatedAtRoute("GetLesson", new { id = newLesson.Id }, _mapper.Map <LessonDTO>(newLesson))); } catch (Exception e) { _logger.LogError($"Error in action `PostLesson()`. {e.Message}"); return(StatusCode(StatusCodes.Status500InternalServerError)); } }