示例#1
0
        public ActionResult <GetSubscriptionsResponse> Get()
        {
            GetSubscriptionsRequest  request  = new GetSubscriptionsRequest();
            GetSubscriptionsResponse response = this._getSubscriptions.Process(request);

            return(response);
        }
示例#2
0
        public ActionResult Index()
        {
            GetSubscriptionsResponse response = _subscriptionsService.List(Customer.CustomerId);

            if (!response.HasPlan)
            {
                return(View("ChangeSubscription", response.ChangeSubscriptionModel));
            }

            return(View(response.SubscriptionModel));
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="mailingListId"></param>
        /// <param name="timestampSince"></param>
        /// <returns></returns>
        public async Task <List <SubscriptionType> > SubscriptionsAsync(string mailingListId = null, string timestampSince = null)
        {
            try
            {
                if (_subscriptions == null)
                {
                    var req = new GetSubscriptionsReq()
                    {
                        header = Client.RequestHeader
                    };

                    if (!string.IsNullOrWhiteSpace(mailingListId))
                    {
                        req.mailingListId = int.Parse(mailingListId);
                    }
                    req.mailingListIdSpecified = true;

                    if (!string.IsNullOrWhiteSpace(timestampSince))
                    {
                        req.timestampSince = timestampSince;
                    }

                    GetSubscriptionsResponse response = await _client.API.GetSubscriptionsAsync(req);

                    _subscriptions = response.GetSubscriptionsResp;
                }

                if (_subscriptions.errorCode == (int)errorCode.No_error)
                {
                    return(_subscriptions.subscriptionTypeItems.ToList <SubscriptionType>());
                }

                throw new FlexMailException(_subscriptions.errorMessage, _subscriptions.errorCode);
            }
            catch (Exception ex)
            {
                ////telemetry.TrackException(ex, new Dictionary<string, string> { { "Flexmail", "Account.Subscriptions" } });
                if (ex is FlexMailException)
                {
                    throw (ex);
                }
            }
            finally
            {
                _subscriptions = null;
            }
            return(new List <SubscriptionType>());
        }
示例#4
0
        public GetSubscriptionsResponse List(Guid customerId)
        {
            var response = new GetSubscriptionsResponse();

            var customer = _customerRepository.Get(customerId);

            if (customer.Plan == null)
            {
                response.HasPlan = false;
                response.ChangeSubscriptionModel.Plans = _planRepository.Query().ToList();
                return(response);
            }

            response.HasPlan = true;


            response.SubscriptionModel = new SubscriptionModel()
            {
                CurrentPlan   = customer.Plan != null ? customer.Plan.Name : string.Empty,
                CurrentPeriod = customer.Plan != null ? customer.Plan.Period : string.Empty,
                CurrentPrice  = customer.Plan != null ? customer.Plan.Price : 0.0M
            };
            return(response);
        }