Ejemplo n.º 1
0
        protected void Page_Init(object sender, EventArgs e)
        {
            if (PublicCustomerInfos == null)
            {
                var loginLinkButton = (HtmlAnchor)ControlExtensions.FindControlRecursive(Master, "LoginLinkButton");
                loginLinkButton.Visible = false;
                Response.Redirect(string.Format(Constant.SignIpPage, HttpUtility.UrlEncode(Request.Url.PathAndQuery)));
            }

            MemberShipDetailView.ActiveViewIndex = 0;
            YourPlanLabel.Text             = ErrorMessage.MembershipNotActive;
            reactiveMembershipLink.Visible = true;
            cancelMembershipLink.Visible   = false;


            _subscriptionBookings = _subscriptionBookingRepository.GetSuspendedByCustomerId(PublicCustomerInfos.CustomerId);

            if (_subscriptionBookings != null)
            {
                PublicDiscounts            = _customerInfoRepository.GetSubscriptionDiscountSuspended(PublicCustomerInfos.CustomerId);
                ErrorMessageLabel.Text     = "Your subscription is suspended. Please contact our customer support at <a href=\"mailto:[email protected]\">[email protected]</a> to resolve this issue.";
                ErrorMessageLabel.Visible  = true;
                ErrorMessageLabel.CssClass = "error-message";
            }

            if (PublicDiscounts != null)
            {
                MemberShipDetailView.ActiveViewIndex = 1;

                _subscriptions = _customerInfoRepository.GetSubscriptionByCustomerId(PublicCustomerInfos.CustomerId, PublicDiscounts.Id);
                if (_subscriptions != null)
                {
                    YourPlanLabel.Text = string.Format("{0} - {1} <br/> {2} / month",
                                                       _subscriptions.Name.ToUpper(),
                                                       _subscriptions.ProductHighlight,
                                                       Helper.FormatPrice(_subscriptions.Price));
                    WhatYouGetLit.Text = _subscriptions.WhatYouGet;
                }

                // Avoid get again by Suspended case
                if (_subscriptionBookings == null)
                {
                    _subscriptionBookings = _subscriptionBookingRepository.GetByCustomerId(PublicCustomerInfos.CustomerId, PublicDiscounts.Id);
                }

                if (_subscriptionBookings != null)
                {
                    switch (_subscriptionBookings.Status)
                    {
                    case (int)Enums.SubscriptionBookingStatus.Active:
                        NextCycleLit.Text = string.Format("Next cycle begins {0:MMMM dd}",
                                                          PublicDiscounts.EndDate.HasValue ?
                                                          PublicDiscounts.EndDate.Value.ToLosAngerlesTime().AddDays(1) : DateTime.UtcNow);
                        reactiveMembershipLink.Visible = false;
                        cancelMembershipLink.Visible   = true;
                        break;

                    case (int)Enums.SubscriptionBookingStatus.End:
                        NextCycleLit.Visible = false;
                        break;

                    case (int)Enums.SubscriptionBookingStatus.Suspended:
                        reactiveMembershipLink.Visible = false;
                        cancelMembershipLink.Visible   = false;
                        break;
                    }
                }

                ValidLit.Text = string.Format("Valid through {0:MMMM dd, yyyy}",
                                              PublicDiscounts.EndDate.HasValue ?
                                              PublicDiscounts.EndDate.Value.ToLosAngerlesTime() : DateTime.UtcNow);
                MembershipIdLabel.Text = PublicDiscounts.Code;
            }
        }