public IActionResult NeverSoldReport()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageOrders))
            {
                return(AccessDeniedView());
            }

            var model = new NeverSoldReportModel();

            return(View(model));
        }
        public IActionResult NeverSoldReportList(DataSourceRequest command, NeverSoldReportModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageOrders))
            {
                return(Content(""));
            }

            //a vendor should have access only to his products
            string vendorId = "";

            if (_workContext.CurrentVendor != null)
            {
                vendorId = _workContext.CurrentVendor.Id;
            }

            DateTime?startDateValue = (model.StartDate == null) ? null
                            : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.StartDate.Value, _dateTimeHelper.CurrentTimeZone);

            DateTime?endDateValue = (model.EndDate == null) ? null
                            : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.EndDate.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1);

            var items = _orderReportService.ProductsNeverSold(vendorId,
                                                              startDateValue, endDateValue,
                                                              command.Page - 1, command.PageSize, true);
            var gridModel = new DataSourceResult
            {
                Data = items.Select(x =>
                                    new NeverSoldReportLineModel
                {
                    ProductId   = x.Id,
                    ProductName = x.Name,
                }),
                Total = items.TotalCount
            };

            return(Json(gridModel));
        }
Esempio n. 3
0
        public async Task <IActionResult> NeverSoldReportList(DataSourceRequest command, NeverSoldReportModel model)
        {
            //a vendor should have access only to his products
            string vendorId = "";

            if (_workContext.CurrentVendor != null)
            {
                vendorId = _workContext.CurrentVendor.Id;
            }

            DateTime?startDateValue = (model.StartDate == null) ? null
                            : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.StartDate.Value, _dateTimeHelper.CurrentTimeZone);

            DateTime?endDateValue = (model.EndDate == null) ? null
                            : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.EndDate.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1);

            string storeId = "";

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

            var items = await _orderReportService.ProductsNeverSold(storeId, vendorId,
                                                                    startDateValue, endDateValue,
                                                                    command.Page - 1, command.PageSize, true);

            var gridModel = new DataSourceResult
            {
                Data = items.Select(x =>
                                    new NeverSoldReportLineModel
                {
                    ProductId   = x.Id,
                    ProductName = x.Name,
                }),
                Total = items.TotalCount
            };

            return(Json(gridModel));
        }
Esempio n. 4
0
        public IActionResult NeverSoldReport()
        {
            var model = new NeverSoldReportModel();

            return(View(model));
        }