public async Task <LessonLevelDTO> CreateAsync(LessonLevelCreateDTO create) { LessonLevel level = _mapper.Map <LessonLevel>(create); level = await _lessonLevelRepository.AddAsync(level); return(_mapper.Map <LessonLevelDTO>(level)); }
public async Task <IActionResult> Create([FromBody] LessonLevelCreateDTO create) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var level = await levelService.CreateAsync(create); return(CreatedAtRoute("GetLessonLevel", new { id = level.Id }, level)); } catch (Exception e) { logger.Fatal(e, $"POST LessonLevels/{nameof(Create)} {create}"); return(InternalServerError()); } }