Exemplo n.º 1
0
        public async void SetDomainDetails(ServerDomain domain)
        {
            following                    = false;
            subscribed                   = false;
            followButton.IsVisible       = false;
            followButton.BackgroundColor = Color.FromHex("#31c3ee");
            currentDomain                = domain;
            if (currentDomain.domainDonation != null)
            {
                if (currentDomain.domainDonation == "Yes")
                {
                    donateDomainButton.IsVisible = true;
                }
            }
            if (!string.IsNullOrEmpty(currentDomain.domainLogo))
            {
                domainLogo.IsVisible = true;
                domainLogo.Source    = currentDomain.domainLogo;
                //logoGrid.BackgroundColor = Color.Transparent;
                Regex  initials = new Regex(@"(\b[a-zA-Z])[a-zA-Z]* ?");
                string init     = initials.Replace(domain.domainName, "$1");
                if (init.Length > 3)
                {
                    init = init.Substring(0, 3);
                }
                logoText.Text = init.ToUpper();
            }
            else
            {
                domainLogo.IsVisible = false;
                //logoGrid.BackgroundColor = Color.FromHex("#31c3ee");
                Regex  initials = new Regex(@"(\b[a-zA-Z])[a-zA-Z]* ?");
                string init     = initials.Replace(domain.domainName, "$1");
                if (init.Length > 3)
                {
                    init = init.Substring(0, 3);
                }
                logoText.Text = init.ToUpper();
            }
            if (!string.IsNullOrEmpty(currentDomain.domainAddress))
            {
                domainAddress.Text = currentDomain.domainAddress;
            }
            else
            {
                domainAddress.IsVisible = false;
            }
            domainName.Text        = currentDomain.domainName;
            domainDescription.Text = currentDomain.domainDescription;
            if (currentDomain.domainType == "Public")
            {
                domainType.Text = "Open Domain";
            }
            else if (currentDomain.domainType == "Private")
            {
                domainType.Text = "Private Domain";
            }
            else
            {
                domainType.Text = "Subscription ( " + currentDomain.domainSubscriptionType + " Payment )";
            }

            if (currentDomain.domainType != "Subscription")
            {
                if (App.serverData.mei_user.registeredDomainList.Where(x => x.firmID == currentDomain.firmID).ToList().Count > 0)
                {
                    following                    = true;
                    followButton.Text            = "UnFollow";
                    followButton.BackgroundColor = Color.FromHex("#ff3232");
                    followButton.IsVisible       = true;
                }

                if (!following)
                {
                    if (currentDomain.domainType == "Private")
                    {
                        followButton.Text      = "Request for Access";
                        followButton.IsVisible = true;
                    }
                    else
                    {
                        followButton.Text      = "Follow Domain";
                        followButton.IsVisible = true;
                    }
                }
                if (App.serverData.mei_user.userRequestedDomainList.Contains(currentDomain.firmID))
                {
                    followButton.Text            = "Cancel Request";
                    followButton.BackgroundColor = Color.FromHex("#ff3232");
                    followButton.IsVisible       = true;
                }
            }
            else
            {
                subscription = App.serverData.mei_user.userSubscriptionList.Find(x => x.planID == currentDomain.subscriptionPlanID);
                if (subscription != null)
                {
                    following  = true;
                    subscribed = true;
                    string subStatus = await App.serverData.GetSubscriptionStatus(subscription.subscriptionID, "sub_status");

                    if (subStatus == "Canceled")
                    {
                        followButton.IsEnabled       = false;
                        followButton.Text            = "Subscription canceled";
                        followButton.BackgroundColor = Color.FromHex("#ff3232");
                        followButton.IsVisible       = true;
                    }
                    else
                    {
                        followButton.IsEnabled       = true;
                        followButton.BackgroundColor = Color.FromHex("#ff3232");
                        followButton.Text            = "Cancel Subscription";
                        followButton.IsVisible       = true;
                    }
                }
                else
                {
                    following              = false;
                    followButton.Text      = "Subscribe";
                    followButton.IsVisible = true;
                }
                if (App.serverData.mei_user.userRequestedDomainList.Where(x => x == currentDomain.firmID).ToList().Count > 0)
                {
                    following                    = true;
                    followButton.Text            = "UnFollow";
                    followButton.BackgroundColor = Color.FromHex("#ff3232");
                    followButton.IsVisible       = true;
                }
            }
        }
        public async void SetAbout()
        {
            eventDescription.IsVisible = true;
            emptyList.IsVisible        = false;
            await((HomeLayout)App.Current.MainPage).SetLoading(true, "Syncing event RSVP status...");
            currentEvent = await((HomeLayout)App.Current.MainPage).GetCurrentDomainEventFromServer();
            if (currentEvent.s_event.eventType != "Subscription")
            {
                cancelSubscription.IsVisible = false;
            }
            else
            {
                subscription = App.serverData.mei_user.userSubscriptionList.Find(x => x.planID == currentEvent.s_event.eventSubscriptionPlanID);
                if (subscription != null)
                {
                    await((HomeLayout)App.Current.MainPage).SetLoading(true, "Syncing event RSVP status...");
                    string subStatus = await App.serverData.GetSubscriptionStatus(subscription.subscriptionID, "sub_status");

                    cancelSubscription.IsVisible = true;
                    if ((subStatus.Equals("Canceled") || subStatus.Equals("Expired")) && currentEvent.s_event.eventSubscriptionType != "Single")
                    {
                        cancelSubscription.IsEnabled = false;
                        if (subStatus.Equals("Canceled"))
                        {
                            cancelSubscription.Text = "Subscription Canceled";
                        }
                        else
                        {
                            cancelSubscription.Text = "Subscription Expired";
                        }
                    }
                    else if (currentEvent.s_event.eventSubscriptionType != "Single")
                    {
                        cancelSubscription.IsVisible = false;
                    }
                }
            }
            if (!string.IsNullOrEmpty(currentEvent.s_event.eventName))
            {
                eventName.Text = currentEvent.s_event.eventName;
            }
            else
            {
                eventName.Text = "No event name";
            }
            if (!string.IsNullOrEmpty(currentEvent.s_event.eventLogo))
            {
                aboutEventLogo.Source = currentEvent.s_event.eventLogo;
                Regex  initials = new Regex(@"(\b[a-zA-Z])[a-zA-Z]* ?");
                string init     = initials.Replace(currentEvent.s_event.eventName, "$1");
                if (init.Length > 3)
                {
                    init = init.Substring(0, 3);
                }
                logoText.Text = init.ToUpper();
            }
            else
            {
                aboutEventLogo.Source = "";
                Regex  initials = new Regex(@"(\b[a-zA-Z])[a-zA-Z]* ?");
                string init     = initials.Replace(currentEvent.s_event.eventName, "$1");
                if (init.Length > 3)
                {
                    init = init.Substring(0, 3);
                }
                logoText.Text = init.ToUpper();
            }
            if (!string.IsNullOrEmpty(currentEvent.s_event.eventVenueName))
            {
                eventVenueName.Text = currentEvent.s_event.eventVenueName;
            }
            else
            {
                eventVenueName.Text = "";
            }
            if (!string.IsNullOrEmpty(currentEvent.s_event.eventAbout))
            {
                eventDescription.Text = currentEvent.s_event.eventAbout;
            }
            else
            {
                eventDescription.IsVisible = false;
                emptyList.IsVisible        = true;
                if (!string.IsNullOrEmpty(currentEvent.s_event.eventDescription))
                {
                    eventDescription.Text = currentEvent.s_event.eventDescription;
                }
                else
                {
                    eventDescription.IsVisible = false;
                    emptyList.IsVisible        = true;
                }
            }
            if (!string.IsNullOrEmpty(currentEvent.s_event.eventAddress))
            {
                eventCityState.Text = currentEvent.s_event.eventAddress;
            }
            else
            {
                eventCityState.Text = "";
            }
            if (currentEvent.s_event.eventStartDate.Equals(currentEvent.s_event.eventEndDate))
            {
                eventDays.Text = BaseFunctions.getMonthDay(currentEvent.s_event.eventStartDate) + ", " + BaseFunctions.getYear(currentEvent.s_event.eventEndDate);
            }
            else
            {
                if (BaseFunctions.GetMonth(currentEvent.s_event.eventStartDate) == BaseFunctions.GetMonth(currentEvent.s_event.eventEndDate))
                {
                    eventDays.Text = BaseFunctions.getMonthDay(currentEvent.s_event.eventStartDate) + " - " + BaseFunctions.getDayYear(currentEvent.s_event.eventEndDate);
                }
                else
                {
                    eventDays.Text = BaseFunctions.getMonthDay(currentEvent.s_event.eventStartDate) + " - " + BaseFunctions.getMonthDay(currentEvent.s_event.eventEndDate) + ", " + BaseFunctions.getYear(currentEvent.s_event.eventEndDate);
                }
            }
            var k = await rsvpTemplate.CheckRSVP();

            await((HomeLayout)App.Current.MainPage).SetLoading(false, "Loading event sessions...");
        }