/* public ActionResult<Book> Get(string id) * { * var book = _chapterService.Get(id); * * if (book == null) * { * return NotFound(); * } * * return book; * } */ public async Task <IActionResult> GetChapterById(string id) { var foundBook = await _chapterService.GetChapterById(id); if (foundBook == null) { return(BadRequest()); } return(Ok(mapper.Map <ChapterViewModel>(foundBook))); }
public async Task <ApiResponse <Chapter> > GetChapter(string id) { try { return(await _chapterService.GetChapterById(new Guid(id))); } catch (Exception ex) { return(new ApiResponse <Chapter>() { Success = false, Errors = new List <string>() { ex.Message } }); } }