コード例 #1
0
        public CommonStatisticsModel PrepareCommonStatisticsModel()
        {
            var model = new CommonStatisticsModel
            {
                NumberOfDayVisitors     = _visitorCounterService.GetCounterCount(DateTime.Now),
                NumberOfCustomers       = _customerService.GetAllCustomers().Count(),
                NumberOfTotalVisitCount = _visitorCounterService.GetByListCounter().Sum(x => x.Count)
            };
            var blogIds         = new List <int>();
            var newsIds         = new List <int>();
            var newsCounterList = _newsCounterService.GetByListCounter(entityName: "NewsItem");

            model.NumberOfNewsRead = newsCounterList.Count;
            foreach (var counter in newsCounterList)
            {
                newsIds.Add(counter.EntityId);
            }
            var blogPostCounetrList = _newsCounterService.GetByListCounter(entityName: "BlogPost");

            model.NumberOfReadBlogPost = blogPostCounetrList.Count;
            foreach (var counter in blogPostCounetrList)
            {
                blogIds.Add(counter.EntityId);
            }
            var newsListIds = _newsService.GetAllNewsItemsIds().ToArray();
            var blogListIds = _blogService.GetBlogListIds().ToArray();

            model.NumberOfNotReadNews     = newsListIds.Except(newsIds).Count();
            model.NumberOfNotReadBlogPost = blogListIds.Except(blogIds).Count();
            return(model);
        }
コード例 #2
0
        /// <summary>
        /// Calculates common statistics
        /// </summary>
        /// <returns>Object with the main statistics data</returns>
        public async Task <CommonStatisticsModel> GetCommonStatistics()
        {
            //Data offered by a view on database, in this way, we not need to read all data
            CommonStatisticsModel statistics = await _dbContext.CommonStatistics.FirstAsync();

            statistics.TotalItems = await _dbContext.MarketRegister.CountAsync();

            return(statistics);
        }
コード例 #3
0
        /// <summary>
        /// Prepare common statistics model
        /// </summary>
        /// <returns>Common statistics model</returns>
        public virtual CommonStatisticsModel PrepareCommonStatisticsModel()
        {
            var model = new CommonStatisticsModel();

            var userRoleIds = new[] { _userService.GetUserRoleBySystemName(NopUserDefaults.RegisteredRoleName).Id };

            model.NumberOfUsers = _userService.GetAllUsers(userRoleIds: userRoleIds,
                                                           pageIndex: 0, pageSize: 1, getOnlyTotalCount: true).TotalCount;

            return(model);
        }
コード例 #4
0
        /// <summary>
        /// Prepare common statistics model
        /// </summary>
        /// <returns>Common statistics model</returns>
        public virtual CommonStatisticsModel PrepareCommonStatisticsModel()
        {
            var model = new CommonStatisticsModel
            {
            };

            var customerRoleIds = new[] { _customerService.GetCustomerRoleBySystemName(GSCustomerDefaults.RegisteredRoleName).Id };

            model.NumberOfCustomers = _customerService.GetAllCustomers(customerRoleIds: customerRoleIds,
                                                                       pageIndex: 0, pageSize: 1, getOnlyTotalCount: true).TotalCount;



            return(model);
        }
コード例 #5
0
        public virtual ActionResult CommonStatistics()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCustomers) ||
                !_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
            {
                return(Content(""));
            }



            var model = new CommonStatisticsModel();

            model.NumberOfCustomers = _customerService.GetAllCustomers(
                customerRoleIds: new [] { _customerService.GetCustomerRoleBySystemName(SystemCustomerRoleNames.Registered).Id },
                pageIndex: 0,
                pageSize: 1).TotalCount;

            return(PartialView(model));
        }
コード例 #6
0
        public IViewComponentResult Invoke()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCustomers) ||
                !_permissionService.Authorize(StandardPermissionProvider.ManageOrders) ||
                !_permissionService.Authorize(StandardPermissionProvider.ManageReturnRequests) ||
                !_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
            {
                return(Content(""));
            }

            //a vendor doesn't have access to this report
            if (_workContext.CurrentVendor != null)
            {
                return(Content(""));
            }

            var model = new CommonStatisticsModel
            {
                NumberOfOrders = _orderService.SearchOrders(
                    pageIndex: 0,
                    pageSize: 1,
                    getOnlyTotalCount: true).TotalCount,

                NumberOfCustomers = _customerService.GetAllCustomers(
                    customerRoleIds: new[] { _customerService.GetCustomerRoleBySystemName(SystemCustomerRoleNames.Registered).Id },
                    pageIndex: 0,
                    pageSize: 1,
                    getOnlyTotalCount: true).TotalCount,

                NumberOfPendingReturnRequests = _returnRequestService.SearchReturnRequests(
                    rs: ReturnRequestStatus.Pending,
                    pageIndex: 0,
                    pageSize: 1,
                    getOnlyTotalCount: true).TotalCount,

                NumberOfLowStockProducts =
                    _productService.GetLowStockProducts(getOnlyTotalCount: true).TotalCount +
                    _productService.GetLowStockProductCombinations(getOnlyTotalCount: true).TotalCount
            };

            return(View(model));
        }
コード例 #7
0
        /// <summary>
        /// Prepare common statistics model
        /// </summary>
        /// <returns>
        /// A task that represents the asynchronous operation
        /// The task result contains the common statistics model
        /// </returns>
        public virtual async Task<CommonStatisticsModel> PrepareCommonStatisticsModelAsync()
        {
            var model = new CommonStatisticsModel
            {
                NumberOfOrders = (await _orderService.SearchOrdersAsync(pageIndex: 0, pageSize: 1, getOnlyTotalCount: true)).TotalCount
            };

            var customerRoleIds = new[] { (await _customerService.GetCustomerRoleBySystemNameAsync(NopCustomerDefaults.RegisteredRoleName)).Id };
            model.NumberOfCustomers = (await _customerService.GetAllCustomersAsync(customerRoleIds: customerRoleIds,
                pageIndex: 0, pageSize: 1, getOnlyTotalCount: true)).TotalCount;

            var returnRequestStatus = ReturnRequestStatus.Pending;
            model.NumberOfPendingReturnRequests = (await _returnRequestService.SearchReturnRequestsAsync(rs: returnRequestStatus,
                pageIndex: 0, pageSize: 1, getOnlyTotalCount: true)).TotalCount;

            model.NumberOfLowStockProducts =
                (await _productService.GetLowStockProductsAsync(getOnlyTotalCount: true)).TotalCount +
                (await _productService.GetLowStockProductCombinationsAsync(getOnlyTotalCount: true)).TotalCount;

            return model;
        }
コード例 #8
0
        /// <summary>
        /// Prepare common statistics model
        /// </summary>
        /// <returns>Common statistics model</returns>
        public virtual CommonStatisticsModel PrepareCommonStatisticsModel()
        {
            var model = new CommonStatisticsModel
            {
                NumberOfOrders = _orderService.SearchOrders(pageIndex: 0, pageSize: 1, getOnlyTotalCount: true).TotalCount
            };

            var customerRoleIds = new[] { _customerService.GetCustomerRoleBySystemName(NopCustomerDefaults.RegisteredRoleName).Id };

            model.NumberOfCustomers = _customerService.GetAllCustomers(customerRoleIds: customerRoleIds,
                                                                       pageIndex: 0, pageSize: 1, getOnlyTotalCount: true).TotalCount;

            var returnRequestStatus = ReturnRequestStatus.Pending;

            model.NumberOfPendingReturnRequests = _returnRequestService.SearchReturnRequests(rs: returnRequestStatus,
                                                                                             pageIndex: 0, pageSize: 1, getOnlyTotalCount: true).TotalCount;

            model.NumberOfLowStockProducts =
                _productService.GetLowStockProducts(getOnlyTotalCount: true).TotalCount +
                _productService.GetLowStockProductCombinations(getOnlyTotalCount: true).TotalCount;

            return(model);
        }
コード例 #9
0
        public virtual ActionResult CommonStatistics()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCustomers) ||
                !_permissionService.Authorize(StandardPermissionProvider.ManageSubscriptions) ||
                !_permissionService.Authorize(StandardPermissionProvider.ManageReturnRequests) ||
                !_permissionService.Authorize(StandardPermissionProvider.ManageArticles))
            {
                return(Content(""));
            }

            //a contributor doesn't have access to this report
            if (_workContext.CurrentContributor != null)
            {
                return(Content(""));
            }

            var model = new CommonStatisticsModel();

            model.NumberOfSubscriptions = _subscriptionService.SearchSubscriptions(
                pageIndex: 0,
                pageSize: 1).TotalCount;

            model.NumberOfCustomers = _customerService.GetAllCustomers(
                customerRoleIds: new [] { _customerService.GetCustomerRoleBySystemName(SystemCustomerRoleNames.Registered).Id },
                pageIndex: 0,
                pageSize: 1).TotalCount;

            model.NumberOfPendingReturnRequests = _returnRequestService.SearchReturnRequests(
                rs: ReturnRequestStatus.Pending,
                pageIndex: 0,
                pageSize: 1).TotalCount;



            return(PartialView(model));
        }