Exemplo n.º 1
0
        public virtual ActionResult AffiliatedSubscriptionList(int affiliateId)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageAffiliates))
            {
                return(Content(""));
            }

            if (affiliateId == 0)
            {
                throw new Exception("Affliate ID cannot be 0");
            }

            var model = new AffiliatedSubscriptionListModel();

            model.AffliateId = affiliateId;

            //subscription statuses
            model.AvailableSubscriptionStatuses = SubscriptionStatus.Pending.ToSelectList(false).ToList();
            model.AvailableSubscriptionStatuses.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"
            });


            return(PartialView(model));
        }
Exemplo n.º 2
0
        public virtual ActionResult AffiliatedSubscriptionListGrid(DataSourceRequest command, AffiliatedSubscriptionListModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageAffiliates))
            {
                return(AccessDeniedKendoGridJson());
            }

            var affiliate = _affiliateService.GetAffiliateById(model.AffliateId);

            if (affiliate == null)
            {
                throw new ArgumentException("No affiliate found with the specified 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 subscriptionStatusIds = model.SubscriptionStatusId > 0 ? new List <int>()
            {
                model.SubscriptionStatusId
            } : null;
            var paymentStatusIds = model.PaymentStatusId > 0 ? new List <int>()
            {
                model.PaymentStatusId
            } : null;
            var shippingStatusIds = model.ShippingStatusId > 0 ? new List <int>()
            {
                model.ShippingStatusId
            } : null;

            var subscriptions = _subscriptionService.SearchSubscriptions(
                createdFromUtc: startDateValue,
                createdToUtc: endDateValue,
                osIds: subscriptionStatusIds,
                psIds: paymentStatusIds,
                ssIds: shippingStatusIds,
                affiliateId: affiliate.Id,
                pageIndex: command.Page - 1,
                pageSize: command.PageSize);
            var gridModel = new DataSourceResult
            {
                Data = subscriptions.Select(subscription =>
                {
                    var subscriptionModel = new AffiliateModel.AffiliatedSubscriptionModel();
                    subscriptionModel.Id  = subscription.Id;
                    subscriptionModel.SubscriptionStatus       = subscription.SubscriptionStatus.GetLocalizedEnum(_localizationService, _workContext);
                    subscriptionModel.SubscriptionStatusId     = subscription.SubscriptionStatusId;
                    subscriptionModel.PaymentStatus            = subscription.PaymentStatus.GetLocalizedEnum(_localizationService, _workContext);
                    subscriptionModel.SubscriptionTotal        = _priceFormatter.FormatPrice(subscription.SubscriptionTotal, true, false);
                    subscriptionModel.CreatedOn                = _dateTimeHelper.ConvertToUserTime(subscription.CreatedOnUtc, DateTimeKind.Utc);
                    subscriptionModel.CustomSubscriptionNumber = subscription.CustomSubscriptionNumber;

                    return(subscriptionModel);
                }),
                Total = subscriptions.TotalCount
            };

            return(Json(gridModel));
        }