Example #1
0
        public async Task <IActionResult> GetAll(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "SubItemDetailGetAll")] HttpRequest req,
            ILogger log)
        {
            int submenuItemId = 0; int page = 1; int size = 20; string keyword = "";

            page          = req.Query["page"].Count == 1?int.Parse(req.Query["page"].ToString()):1;
            size          = req.Query["size"].Count == 1 ? int.Parse(req.Query["size"].ToString()):20;
            submenuItemId = req.Query["submenuItemId"].Count == 1 ?  int.Parse(req.Query["submenuItemId"].ToString()):0;
            keyword       = req.Query["keyword"].ToString();

            log.LogInformation("Got sub item details");
            if (page < 1)
            {
                return(new BadRequestObjectResult("page can't be negative."));
            }
            if (size < 1)
            {
                return(new BadRequestObjectResult("Page size can't be negative"));
            }

            var temp = await repo.GetPageData <SubItemDetailModel>(submenuItemId, page, size, keyword);

            req.HttpContext.Response.Headers.Add("pagesQuantity", temp.Item2.ToString());
            return(new OkObjectResult(temp.Item1));
        }
Example #2
0
        public async Task <IActionResult> Get(int submenuItemId = 0, int page = 1, int size = 20, string keyword = "")
        {
            if (page < 1)
            {
                return(BadRequest("page can't be negative."));
            }
            if (size < 1)
            {
                return(BadRequest("Page size can't be negative"));
            }

            var temp = await repo.GetPageData <SubItemDetailModel>(submenuItemId, page, size, keyword);

            HttpContext.InsertPaginationParameterInResponse(temp.Item2);
            return(Ok(temp.Item1));
        }