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; //return first 100 records //group by product variants (not products) var items = _orderReportService.BestSellersReport(startDateValue, endDateValue, orderStatus, paymentStatus, null, model.BillingCountryId, 100, 2, 1, true); var gridModel = new GridModel<BestsellersReportLineModel> { Data = items.Select(x => { var m = new BestsellersReportLineModel() { ProductVariantId = x.EntityId, TotalAmount = _priceFormatter.FormatPrice(x.TotalAmount, true, false), TotalQuantity = x.TotalQuantity, }; var productVariant = _productService.GetProductVariantById(x.EntityId); if (productVariant != null) m.ProductVariantFullName = productVariant.Product.Name + " " + productVariant.Name; return m; }), Total = items.Count }; return new JsonResult { Data = gridModel }; }
public ActionResult BestsellersReport() { var model = new BestsellersReportModel(); //order statuses model.AvailableOrderStatuses = OrderStatus.Pending.ToSelectList(false).ToList(); model.AvailableOrderStatuses.Insert(0, new SelectListItem() { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); //payment statuses model.AvailablePaymentStatuses = PaymentStatus.Pending.ToSelectList(false).ToList(); model.AvailablePaymentStatuses.Insert(0, new SelectListItem() { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); //billing countries foreach (var c in _countryService.GetAllCountriesForBilling()) { model.AvailableCountries.Add(new SelectListItem() { Text = c.Name, Value = c.Id.ToString() }); } model.AvailableCountries.Insert(0, new SelectListItem() { Text = _localizationService.GetResource("Admin.Address.SelectCountry"), Value = "0" }); return View(model); }
public ActionResult BestsellersReport() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageOrders)) return AccessDeniedView(); var model = new BestsellersReportModel(); //order statuses model.AvailableOrderStatuses = OrderStatus.Pending.ToSelectList(false).ToList(); model.AvailableOrderStatuses.Insert(0, new SelectListItem() { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); //payment statuses model.AvailablePaymentStatuses = PaymentStatus.Pending.ToSelectList(false).ToList(); model.AvailablePaymentStatuses.Insert(0, new SelectListItem() { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); //categories model.AvailableCategories.Add(new SelectListItem() { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); foreach (var c in _categoryService.GetAllCategories(showHidden: true)) model.AvailableCategories.Add(new SelectListItem() { Text = c.GetFormattedBreadCrumb(_categoryService), Value = c.Id.ToString() }); //manufacturers model.AvailableManufacturers.Add(new SelectListItem() { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); foreach (var m in _manufacturerService.GetAllManufacturers(showHidden: true)) model.AvailableManufacturers.Add(new SelectListItem() { Text = m.Name, Value = m.Id.ToString() }); //billing countries foreach (var c in _countryService.GetAllCountriesForBilling()) { model.AvailableCountries.Add(new SelectListItem() { Text = c.Name, Value = c.Id.ToString() }); } model.AvailableCountries.Insert(0, new SelectListItem() { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); //vendor model.IsLoggedInAsVendor = _workContext.CurrentVendor != null; return View(model); }
public ActionResult BestsellersReportList(GridCommand command, BestsellersReportModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageOrders)) return Content(""); //a vendor should have access only to his products int vendorId = 0; 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); OrderStatus? orderStatus = model.OrderStatusId > 0 ? (OrderStatus?)(model.OrderStatusId) : null; PaymentStatus? paymentStatus = model.PaymentStatusId > 0 ? (PaymentStatus?)(model.PaymentStatusId) : null; var items = _orderReportService.BestSellersReport( createdFromUtc: startDateValue, createdToUtc: endDateValue, os: orderStatus, ps: paymentStatus, billingCountryId: model.BillingCountryId, orderBy: 2, vendorId: vendorId, categoryId: model.CategoryId, manufacturerId: model.ManufacturerId, pageIndex: command.Page - 1, pageSize: command.PageSize, showHidden: true); var gridModel = new GridModel<BestsellersReportLineModel> { Data = items.Select(x => { var m = new BestsellersReportLineModel() { ProductId = x.ProductId, TotalAmount = _priceFormatter.FormatPrice(x.TotalAmount, true, false), TotalQuantity = x.TotalQuantity, }; var product = _productService.GetProductById(x.ProductId); if (product!= null) m.ProductName = product.Name; return m; }), Total = items.TotalCount }; return new JsonResult { Data = gridModel }; }
public ActionResult BestsellersReport() { var model = new BestsellersReportModel(); model.AvailableOrderStatuses = OrderStatus.Pending.ToSelectList(false).ToList(); model.AvailableOrderStatuses.Insert(0, new SelectListItem() { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); model.AvailablePaymentStatuses = PaymentStatus.Pending.ToSelectList(false).ToList(); model.AvailablePaymentStatuses.Insert(0, new SelectListItem() { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); return View(model); }