public ActionResult List(DiscountListModel model, DataSourceRequest command) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageDiscounts)) return AccessDeniedView(); DiscountType? discountType = null; if (model.SearchDiscountTypeId > 0) discountType = (DiscountType) model.SearchDiscountTypeId; var discounts = _discountService.GetAllDiscounts(discountType, model.SearchDiscountCouponCode, model.SearchDiscountName, true); var gridModel = new DataSourceResult { Data = discounts.PagedForCommand(command).Select(x => { var discountModel = x.ToModel(); discountModel.DiscountTypeName = x.DiscountType.GetLocalizedEnum(_localizationService, _workContext); discountModel.PrimaryStoreCurrencyCode = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode; discountModel.TimesUsed = _discountService.GetAllDiscountUsageHistory(x.Id, pageSize: 1).TotalCount; return discountModel; }), Total = discounts.Count }; return Json(gridModel); }
public ActionResult List() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageDiscounts)) return AccessDeniedView(); var model = new DiscountListModel(); model.AvailableDiscountTypes = DiscountType.AssignedToOrderTotal.ToSelectList(false).ToList(); model.AvailableDiscountTypes.Insert(0, new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); return View(model); }