public ActionResult BestsellersReportList(GridCommand command, BestsellersReportModel model) { 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); OrderStatus? orderStatus = model.OrderStatusId > 0 ? (OrderStatus?)(model.OrderStatusId) : null; PaymentStatus? paymentStatus = model.PaymentStatusId > 0 ? (PaymentStatus?)(model.PaymentStatusId) : null; var items = _orderReportService.BestSellersReport(0, startDateValue, endDateValue, orderStatus, paymentStatus, null, model.BillingCountryId, 100, 2, true); var gridModel = new GridModel<BestsellersReportLineModel> { Data = items.Select(x => { var product = _productService.GetProductById(x.ProductId); var m = new BestsellersReportLineModel() { ProductId = x.ProductId, TotalAmount = _priceFormatter.FormatPrice(x.TotalAmount, true, false), TotalQuantity = x.TotalQuantity }; if (product != null) { m.ProductName = product.Name; m.ProductTypeName = product.GetProductTypeLabel(_localizationService); m.ProductTypeLabelHint = product.ProductTypeLabelHint; } return m; }), Total = items.Count }; return new JsonResult { Data = gridModel }; }
protected IList<BestsellersReportLineModel> GetBestsellersBriefReportModel(int recordsToReturn, int orderBy) { var report = _orderReportService.BestSellersReport(0, null, null, null, null, null, 0, recordsToReturn, orderBy, true); var model = report.Select(x => { var product = _productService.GetProductById(x.ProductId); var m = new BestsellersReportLineModel() { ProductId = x.ProductId, TotalAmount = _priceFormatter.FormatPrice(x.TotalAmount, true, false), TotalQuantity = x.TotalQuantity, }; if (product != null) { m.ProductName = product.Name; m.ProductTypeName = product.GetProductTypeLabel(_localizationService); m.ProductTypeLabelHint = product.ProductTypeLabelHint; } return m; }).ToList(); return model; }