Exemplo n.º 1
0
        public IActionResult GetProductByDescription(string description, int?page, int?pageSize)

        {
            try
            {
                int pageValue     = ValidatePageValue(page);
                int pageSizeValue = ValidatePageSizeValue(pageSize);
                var data          = _logic.FindProductByDescription(description, pageValue, pageSizeValue);
                var results       = preparePagination(data, pageValue, pageSizeValue);

                return(Ok(results));
            }
            catch (BadRequestException e)
            {
                return(BadRequest(new HttpErrorResponse()
                {
                    Message = e.Message,
                    Subject = e.Subject
                }));
            }
            catch (NotFoundException e)
            {
                return(NotFound(new HttpErrorResponse()
                {
                    Message = e.Message,
                    Subject = e.Subject
                }));
            }
            catch (Exception e)
            {
                //Log Error
                return(StatusCode(500, new HttpErrorResponse()
                {
                    Message = "Internal Error Occurred",
                    Subject = "Internal"
                }));
            }
        }