Exemple #1
0
        public IActionResult GetProductByTitle(string title, int?page, int?pageSize)

        {
            try
            {
                int pageValue     = ValidatePageValue(page);
                int pageSizeValue = ValidatePageSizeValue(pageSize);
                var data          = _logic.FindProductByTitle(title, 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"
                }));
            }
        }