public void GetByCategoryTestmethod(string category) { HttpClient client = TestServer.GetClient(); IMegatokyoClient service = new MegatokyoClient(client); ChapterOutputDTO result = service.GetChapterAsync(category).GetAwaiter().GetResult(); Assert.IsTrue(result.Category == category); }
public async Task <IActionResult> GetChapter(string category) { try { ChapterDomain ChapterData = await _mediator.Send(new GetChapterQuery(category)); ChapterOutputDTO chapter = _mapper.Map <ChapterOutputDTO>(ChapterData); return(Ok(chapter)); } catch (ArgumentException ex) { return(BadRequest(ex.Message)); } catch { throw; } }
public async Task <IActionResult> GetAllChapters() { try { List <ChapterOutputDTO> chaptersData = new(); IEnumerable <ChapterDomain> chapters = await _mediator.Send(new GetAllChaptersQuery()); if (!chapters.Any()) { return(NoContent()); } foreach (ChapterDomain chapter in chapters) { ChapterOutputDTO chapterOutputDTO = _mapper.Map <ChapterOutputDTO>(chapter); chaptersData.Add(chapterOutputDTO); } return(Ok(chaptersData)); } catch { throw; } }