Пример #1
0
        public IActionResult Get(int page)
        {
            string userId     = User.FindFirst(ClaimTypes.NameIdentifier).Value;
            int    totalPlans = 0;

            if (page == 0)
            {
                page = 1;
            }
            var plans = _plansService.GetAllPlansAsync(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 received successfully!",
                OperationDate = DateTime.UtcNow,
                PageSize = PAGE_SIZE,
                Page = page,
                Records = plans
            }));
        }