Exemplo n.º 1
0
        public IActionResult Get(string query, int page)
        {
            string userId     = User.FindFirst(ClaimTypes.NameIdentifier).Value;
            int    totalPlans = 0;

            if (page == 0)
            {
                page = 1;
            }
            var plans = _plansService.SearchPlansAsync(query, PAGE_SIZE, page, userId, out totalPlans);

            int totalPages = 0;

            if (totalPlans % PAGE_SIZE == 0)
            {
                totalPages = totalPlans / PAGE_SIZE;
            }
            else
            {
                totalPages = (totalPlans / PAGE_SIZE) + 1;
            }

            return(Ok(new CollectionPagingResponse <Plan>
            {
                Count = totalPlans,
                IsSuccess = true,
                Message = $"Plans of '{query}' received successfully!",
                OperationDate = DateTime.UtcNow,
                PageSize = PAGE_SIZE,
                Page = page,
                Records = plans
            }));
        }