Ejemplo n.º 1
0
        public async Task <MonitorConfigIndexViewModel> GetMonitorConfigs(int pageIndex, int itemsPage)
        {
            _logger.LogInformation("GetMonitorConfigs called.");

            var filterSpecification          = new MonitorConfigFilterSpecification();
            var filterPaginatedSpecification = new MonitorConfigFilterPaginatedSpecification(itemsPage * pageIndex, itemsPage);

            var itemsOnPage = _repository.List(filterPaginatedSpecification).ToList();
            var totalItems  = _repository.Count(filterSpecification);

            var vm = new MonitorConfigIndexViewModel()
            {
                MonitorConfigs = itemsOnPage.Select(w => new MonitorConfigViewModel()
                {
                    Id       = w.Id,
                    Name     = w.Name,
                    Url      = w.Url,
                    Interval = (int)Math.Round(w.Interval.TotalSeconds)
                }),
                PaginationInfo = new PaginationInfoViewModel()
                {
                    ActualPage   = pageIndex,
                    ItemsPerPage = itemsOnPage.Count,
                    TotalItems   = totalItems,
                    TotalPages   = int.Parse(Math.Ceiling(((decimal)totalItems / itemsPage)).ToString())
                }
            };

            return(vm);
        }
Ejemplo n.º 2
0
        public int GetTotalPages(int itemsPage)
        {
            var filterSpecification = new MonitorConfigFilterSpecification();

            var totalItems = _repository.Count(filterSpecification);

            var totalPages = int.Parse(Math.Ceiling(((decimal)totalItems / itemsPage)).ToString());

            return(totalPages);
        }