Esempio n. 1
0
        public async Task <IActionResult> OrderAverageReportList(DataSourceRequest command)
        {
            if (!await _permissionService.Authorize(StandardPermission.ManageOrders))
            {
                return(Content(""));
            }

            //a vendor does have access to this report
            if (_workContext.CurrentVendor != null && !await _groupService.IsStaff(_workContext.CurrentCustomer))
            {
                return(Content(""));
            }

            string storeId = "";

            if (await _groupService.IsStaff(_workContext.CurrentCustomer))
            {
                storeId = _workContext.CurrentCustomer.StaffStoreId;
            }

            var report = new List <OrderAverageReportLineSummary>
            {
                await _orderReportService.OrderAverageReport(storeId, (int)OrderStatusSystem.Pending),
                await _orderReportService.OrderAverageReport(storeId, (int)OrderStatusSystem.Processing),
                await _orderReportService.OrderAverageReport(storeId, (int)OrderStatusSystem.Complete),
                await _orderReportService.OrderAverageReport(storeId, (int)OrderStatusSystem.Cancelled)
            };

            var statuses = await _orderStatusService.GetAll();

            var model = report.Select(x => new OrderAverageReportLineSummaryModel
            {
                OrderStatus        = statuses.FirstOrDefault(y => y.StatusId == x.OrderStatus)?.Name,
                SumTodayOrders     = _priceFormatter.FormatPrice(x.SumTodayOrders, false),
                SumThisWeekOrders  = _priceFormatter.FormatPrice(x.SumThisWeekOrders, false),
                SumThisMonthOrders = _priceFormatter.FormatPrice(x.SumThisMonthOrders, false),
                SumThisYearOrders  = _priceFormatter.FormatPrice(x.SumThisYearOrders, false),
                SumAllTimeOrders   = _priceFormatter.FormatPrice(x.SumAllTimeOrders, false),
            }).ToList();

            var gridModel = new DataSourceResult
            {
                Data  = model,
                Total = model.Count
            };

            return(Json(gridModel));
        }
Esempio n. 2
0
        public async Task <IActionResult> OrderAverageReportList(DataSourceRequest command)
        {
            if (!await _permissionService.Authorize(StandardPermissionProvider.ManageOrders))
            {
                return(Content(""));
            }

            //a vendor does have access to this report
            if (_workContext.CurrentVendor != null && !_workContext.CurrentCustomer.IsStaff())
            {
                return(Content(""));
            }

            string storeId = "";

            if (_workContext.CurrentCustomer.IsStaff())
            {
                storeId = _workContext.CurrentCustomer.StaffStoreId;
            }

            var report = new List <OrderAverageReportLineSummary>
            {
                await _orderReportService.OrderAverageReport(storeId, OrderStatus.Pending),
                await _orderReportService.OrderAverageReport(storeId, OrderStatus.Processing),
                await _orderReportService.OrderAverageReport(storeId, OrderStatus.Complete),
                await _orderReportService.OrderAverageReport(storeId, OrderStatus.Cancelled)
            };
            var model = report.Select(x => new OrderAverageReportLineSummaryModel
            {
                OrderStatus        = x.OrderStatus.GetLocalizedEnum(_localizationService, _workContext),
                SumTodayOrders     = _priceFormatter.FormatPrice(x.SumTodayOrders, true, false),
                SumThisWeekOrders  = _priceFormatter.FormatPrice(x.SumThisWeekOrders, true, false),
                SumThisMonthOrders = _priceFormatter.FormatPrice(x.SumThisMonthOrders, true, false),
                SumThisYearOrders  = _priceFormatter.FormatPrice(x.SumThisYearOrders, true, false),
                SumAllTimeOrders   = _priceFormatter.FormatPrice(x.SumAllTimeOrders, true, false),
            }).ToList();

            var gridModel = new DataSourceResult
            {
                Data  = model,
                Total = model.Count
            };

            return(Json(gridModel));
        }