Exemplo n.º 1
0
        public async Task <IActionResult> GetCategoryStrips(string category)
        {
            try
            {
                List <StripOutputDTO>     stripsData = new();
                IEnumerable <StripDomain> strips     = await _mediator.Send(new GetCategoryStripsQuery(category));

                if (!strips.Any())
                {
                    return(NoContent());
                }
                foreach (StripDomain strip in strips)
                {
                    StripOutputDTO stripOutputDTO = _mapper.Map <StripOutputDTO>(strip);
                    stripsData.Add(stripOutputDTO);
                }
                return(Ok(stripsData));
            }
            catch (ArgumentException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 2
0
        public void GetByCategoryTestmethod(int number)
        {
            HttpClient       client  = TestServer.GetClient();
            IMegatokyoClient service = new MegatokyoClient(client);
            StripOutputDTO   result  = service.GetStripAsync(number).GetAwaiter().GetResult();

            Assert.IsTrue(result.Number == number);
        }
Exemplo n.º 3
0
        public async Task <IActionResult> GetStrip(int number)
        {
            try
            {
                StripDomain stripData = await _mediator.Send(new GetStripQuery(number));

                StripOutputDTO strip = _mapper.Map <StripOutputDTO>(stripData);
                return(Ok(strip));
            }
            catch (ArgumentException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 4
0
        public async Task <IActionResult> GetAllStrips()
        {
            try
            {
                List <StripOutputDTO>     stripsData = new();
                IEnumerable <StripDomain> strips     = await _mediator.Send(new GetAllStripsQuery());

                if (!strips.Any())
                {
                    return(NoContent());
                }
                foreach (StripDomain strip in strips)
                {
                    StripOutputDTO stripOutputDTO = _mapper.Map <StripOutputDTO>(strip);
                    stripsData.Add(stripOutputDTO);
                }
                return(Ok(stripsData));
            }
            catch
            {
                throw;
            }
        }