Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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;
            }
        }
Ejemplo n.º 3
0
        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;
            }
        }