/// <summary>
        /// Handles the index view request.
        /// </summary>
        /// <param name="customerId">The customer identifier.</param>
        /// <param name="subscriptionId">The subscription identifier.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">
        /// customerId
        /// or
        /// subscriptionId
        /// </exception>
        public async Task <ActionResult> Index(string customerId, string subscriptionId)
        {
            Customer                customer;
            IAggregatePartner       operations;
            SubscriptionHealthModel healthModel;
            Subscription            subscription;

            if (string.IsNullOrEmpty(customerId))
            {
                throw new ArgumentNullException(nameof(customerId));
            }
            if (string.IsNullOrEmpty(subscriptionId))
            {
                throw new ArgumentNullException(nameof(subscriptionId));
            }

            try
            {
                operations = await new SdkContext().GetPartnerOperationsAysnc();
                customer   = await operations.Customers.ById(customerId).GetAsync();

                subscription = await operations.Customers.ById(customerId).Subscriptions.ById(subscriptionId).GetAsync();

                healthModel = new SubscriptionHealthModel
                {
                    CompanyName    = customer.CompanyProfile.CompanyName,
                    CustomerId     = customerId,
                    FriendlyName   = subscription.FriendlyName,
                    SubscriptionId = subscriptionId,
                    ViewModel      = (subscription.BillingType == BillingType.License) ? "Office" : "Azure"
                };

                if (subscription.BillingType == BillingType.Usage)
                {
                    healthModel.HealthEvents = await GetAzureSubscriptionHealthAsync(customerId, subscriptionId);
                }
                else
                {
                    healthModel.HealthEvents = await GetOfficeSubscriptionHealthAsync(customerId);
                }

                return(View(healthModel.ViewModel, healthModel));
            }
            finally
            {
                customer     = null;
                subscription = null;
            }
        }
Example #2
0
        /// <summary>
        /// Handles the index view request.
        /// </summary>
        /// <param name="customerId">The customer identifier.</param>
        /// <param name="subscriptionId">The subscription identifier.</param>
        /// <returns>The HTML template for the index page.</returns>
        /// <exception cref="ArgumentException">
        /// <paramref name="customerId"/> is empty or null.
        /// or
        /// <paramref name="subscriptionId"/> is empty or null.
        /// </exception>
        public async Task <ActionResult> Index(string customerId, string subscriptionId)
        {
            Customer                customer;
            List <IHealthEvent>     events;
            SubscriptionHealthModel healthModel;
            Subscription            subscription;

            customerId.AssertNotEmpty(nameof(customerId));
            subscriptionId.AssertNotEmpty(nameof(subscriptionId));

            try
            {
                customer = await Provider.PartnerOperations.GetCustomerAsync(customerId).ConfigureAwait(false);

                subscription = await Provider.PartnerOperations.GetSubscriptionAsync(customerId, subscriptionId).ConfigureAwait(false);

                healthModel = new SubscriptionHealthModel
                {
                    CompanyName    = customer.CompanyProfile.CompanyName,
                    CustomerId     = customerId,
                    FriendlyName   = subscription.FriendlyName,
                    SubscriptionId = subscriptionId,
                    ViewModel      = (subscription.BillingType == BillingType.License) ? "Office" : "Azure"
                };

                if (subscription.BillingType == BillingType.Usage)
                {
                    events = await GetAzureSubscriptionHealthAsync(customerId, subscriptionId).ConfigureAwait(false);
                }
                else
                {
                    events = await GetOfficeSubscriptionHealthAsync(customerId).ConfigureAwait(false);
                }

                healthModel.HealthEvents.AddRange(events);

                return(View(healthModel.ViewModel, healthModel));
            }
            finally
            {
                customer     = null;
                subscription = null;
            }
        }
Example #3
0
        /// <summary>
        /// Handles the index view request.
        /// </summary>
        /// <param name="customerId">The customer identifier.</param>
        /// <param name="subscriptionId">The subscription identifier.</param>
        /// <returns>The HTML template for the index page.</returns>
        /// <exception cref="ArgumentException">
        /// <paramref name="customerId"/> is empty or null.
        /// or
        /// <paramref name="subscriptionId"/> is empty or null.
        /// </exception>
        public async Task <ActionResult> Index(string customerId, string subscriptionId)
        {
            Customer customer;
            SubscriptionHealthModel healthModel;
            Subscription            subscription;

            customerId.AssertNotEmpty(nameof(customerId));
            subscriptionId.AssertNotEmpty(nameof(subscriptionId));

            try
            {
                customer = await this.Service.PartnerCenter.Customers.ById(customerId).GetAsync();

                subscription = await this.Service.PartnerCenter.Customers.ById(customerId).Subscriptions.ById(subscriptionId).GetAsync();

                healthModel = new SubscriptionHealthModel
                {
                    CompanyName    = customer.CompanyProfile.CompanyName,
                    CustomerId     = customerId,
                    FriendlyName   = subscription.FriendlyName,
                    SubscriptionId = subscriptionId,
                    ViewModel      = (subscription.BillingType == BillingType.License) ? "Office" : "Azure"
                };

                if (subscription.BillingType == BillingType.Usage)
                {
                    healthModel.HealthEvents = await this.GetAzureSubscriptionHealthAsync(customerId, subscriptionId);
                }
                else
                {
                    healthModel.HealthEvents = await this.GetOfficeSubscriptionHealthAsync(customerId);
                }

                return(this.View(healthModel.ViewModel, healthModel));
            }
            finally
            {
                customer     = null;
                subscription = null;
            }
        }