コード例 #1
0
        public ActionResult List()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageGiftCards))
                return AccessDeniedView();

            var model = new GiftCardListModel();
            model.ActivatedList.Add(new SelectListItem()
                {
                    Value = "0",
                    Selected = true,
                    Text = _localizationService.GetResource("Common.All", logIfNotFound: false, defaultValue: "All")
                });
            model.ActivatedList.Add(new SelectListItem()
            {
                Value = "1",
                Text = _localizationService.GetResource("Common.Activated", logIfNotFound: false, defaultValue: "Activated")
            });
            model.ActivatedList.Add(new SelectListItem()
            {
                Value = "2",
                Text = _localizationService.GetResource("Common.Deactivated", logIfNotFound: false, defaultValue: "Deactivated")
            });
            return View(model);
        }
コード例 #2
0
        public ActionResult GiftCardList(GridCommand command, GiftCardListModel model)
        {
            if (!_services.Permissions.Authorize(StandardPermissionProvider.ManageGiftCards))
                return AccessDeniedView();

            bool? isGiftCardActivated = null;
            if (model.ActivatedId == 1)
                isGiftCardActivated = true;
            else if (model.ActivatedId == 2)
                isGiftCardActivated = false;
            var giftCards = _giftCardService.GetAllGiftCards(null, null, null, isGiftCardActivated, model.CouponCode);
            var gridModel = new GridModel<GiftCardModel>
            {
                Data = giftCards.PagedForCommand(command).Select(x =>
                {
                    var m = x.ToModel();
                    m.RemainingAmountStr = _priceFormatter.FormatPrice(x.GetGiftCardRemainingAmount(), true, false);
                    m.AmountStr = _priceFormatter.FormatPrice(x.Amount, true, false);
                    m.CreatedOn = _dateTimeHelper.ConvertToUserTime(x.CreatedOnUtc, DateTimeKind.Utc);
                    return m;
                }),
                Total = giftCards.Count()
            };
            return new JsonResult
            {
                Data = gridModel
            };
        }