示例#1
0
        public async Task <OfferCatalogViewModel> GetOffersCatalog()
        {
            var isBrandingConfigured = ApplicationDomain.Instance.PortalBranding.IsConfiguredAsync();
            var isOffersConfigured   = ApplicationDomain.Instance.OffersRepository.IsConfiguredAsync();
            var isPaymentConfigured  = ApplicationDomain.Instance.PaymentConfigurationRepository.IsConfiguredAsync();

            var getMicrosoftOffersTask = ApplicationDomain.Instance.OffersRepository.RetrieveMicrosoftOffersAsync();
            var getPartnerOffersTask   = ApplicationDomain.Instance.OffersRepository.RetrieveAsync();

            await Task.WhenAll(isBrandingConfigured, isOffersConfigured, isPaymentConfigured);

            var offerCatalogViewModel = new OfferCatalogViewModel();

            offerCatalogViewModel.IsPortalConfigured = isBrandingConfigured.Result && isOffersConfigured.Result && isPaymentConfigured.Result;

            if (offerCatalogViewModel.IsPortalConfigured)
            {
                await Task.WhenAll(getMicrosoftOffersTask, getPartnerOffersTask);

                var microsoftOffers = getMicrosoftOffersTask.Result;
                var partnerOffers   = getPartnerOffersTask.Result.Where(offer => offer.IsInactive == false);

                foreach (var offer in partnerOffers)
                {
                    offer.Thumbnail = microsoftOffers.Where(msOffer => msOffer.Offer.Id == offer.MicrosoftOfferId).First().ThumbnailUri;
                }

                offerCatalogViewModel.Offers = partnerOffers;
            }

            return(offerCatalogViewModel);
        }
        public async Task <OfferCatalogViewModel> GetOffersCatalog()
        {
            var isBrandingConfigured = ApplicationDomain.Instance.PortalBranding.IsConfiguredAsync();
            var isOffersConfigured   = ApplicationDomain.Instance.OffersRepository.IsConfiguredAsync();
            var isPaymentConfigured  = ApplicationDomain.Instance.PaymentConfigurationRepository.IsConfiguredAsync();

            var getMicrosoftOffersTask = ApplicationDomain.Instance.OffersRepository.RetrieveMicrosoftOffersAsync();
            var getPartnerOffersTask   = ApplicationDomain.Instance.OffersRepository.RetrieveAsync();

            await Task.WhenAll(isBrandingConfigured, isOffersConfigured, isPaymentConfigured);

            var offerCatalogViewModel = new OfferCatalogViewModel();

            offerCatalogViewModel.IsPortalConfigured = isBrandingConfigured.Result && isOffersConfigured.Result && isPaymentConfigured.Result;

            if (offerCatalogViewModel.IsPortalConfigured)
            {
                await Task.WhenAll(getMicrosoftOffersTask, getPartnerOffersTask);

                var microsoftOffers = getMicrosoftOffersTask.Result;
                var partnerOffers   = getPartnerOffersTask.Result.Where(offer => offer.IsInactive == false);

                foreach (var offer in partnerOffers)
                {
                    // TODO :: Handle Microsoft offer being pulled back due to EOL.
                    var microsoftOfferItem = microsoftOffers.Where(msOffer => msOffer.Offer.Id == offer.MicrosoftOfferId).FirstOrDefault();

                    // temporarily remove the partner offer from catalog display if the corresponding Microsoft offer does not exist.
                    if (microsoftOfferItem != null)
                    {
                        offer.Thumbnail = microsoftOfferItem.ThumbnailUri;
                    }
                    else
                    {
                        // temporary fix - remove the items from the collection by marking it as Inactive.
                        offer.IsInactive = true;
                    }
                }

                offerCatalogViewModel.Offers = partnerOffers.Where(offer => offer.IsInactive == false);
            }

            return(offerCatalogViewModel);
        }
示例#3
0
        public async Task <OfferCatalogViewModel> GetOffersCatalog()
        {
            bool isBrandingConfigured = await ApplicationDomain.Instance.PortalBranding.IsConfiguredAsync().ConfigureAwait(false);

            bool isOffersConfigured = await ApplicationDomain.Instance.OffersRepository.IsConfiguredAsync().ConfigureAwait(false);

            bool isPaymentConfigured = await ApplicationDomain.Instance.PaymentConfigurationRepository.IsConfiguredAsync().ConfigureAwait(false);

            IEnumerable <MicrosoftOffer> microsoftOffers = await ApplicationDomain.Instance.OffersRepository.RetrieveMicrosoftOffersAsync().ConfigureAwait(false);

            IEnumerable <PartnerOffer> partnerOffers = await ApplicationDomain.Instance.OffersRepository.RetrieveAsync().ConfigureAwait(false);


            OfferCatalogViewModel offerCatalogViewModel = new OfferCatalogViewModel
            {
                IsPortalConfigured = isBrandingConfigured && isOffersConfigured && isPaymentConfigured
            };

            if (offerCatalogViewModel.IsPortalConfigured)
            {
                foreach (PartnerOffer offer in partnerOffers)
                {
                    // TODO :: Handle Microsoft offer being pulled back due to EOL.
                    MicrosoftOffer microsoftOfferItem = microsoftOffers.FirstOrDefault(msOffer => msOffer.Offer.Id == offer.MicrosoftOfferId);

                    // temporarily remove the partner offer from catalog display if the corresponding Microsoft offer does not exist.
                    if (microsoftOfferItem != null)
                    {
                        offer.Thumbnail = microsoftOfferItem.ThumbnailUri;
                    }
                    else
                    {
                        // temporary fix - remove the items from the collection by marking it as Inactive.
                        offer.IsInactive = true;
                    }
                }

                offerCatalogViewModel.Offers = partnerOffers.OrderBy(o => o.DisplayIndex).Where(offer => !offer.IsInactive);
            }

            return(offerCatalogViewModel);
        }