Esempio n. 1
0
        /* 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)));
        }
Esempio n. 2
0
 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
             }
         });
     }
 }