public virtual async Task <RecurringOrderTemplateViewModel> CreateRecurringOrderTemplateDetailsViewModel(CreateRecurringOrderTemplateDetailsViewModelParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.CultureInfo)), nameof(param));
            }
            if (param.ProductImageInfo == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.ProductImageInfo)), nameof(param));
            }
            if (param.ProductImageInfo.ImageUrls == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.ProductImageInfo.ImageUrls)), nameof(param));
            }
            if (param.ScopeId == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.ScopeId)), nameof(param));
            }
            if (param.RecurringOrderLineItem == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.RecurringOrderLineItem)), nameof(param));
            }

            var vm = new RecurringOrderTemplateViewModel();

            var imgDictionary = LineItemHelper.BuildImageDictionaryFor(param.ProductImageInfo.ImageUrls);

            var recurringScheduleUrl = RecurringScheduleUrlProvider.GetRecurringScheduleUrl(new GetRecurringScheduleUrlParam
            {
                CultureInfo = param.CultureInfo
            });

            var lineItemViewModel = await MapToTemplateLineItemViewModel(new MapToTemplateLineItemViewModelParam
            {
                RecurringOrderlineItem = param.RecurringOrderLineItem,
                CultureInfo            = param.CultureInfo,
                ImageDictionnary       = imgDictionary,
                BaseUrl = param.BaseUrl,
                RecurringScheduleUrl = recurringScheduleUrl
            }).ConfigureAwait(false);

            if (lineItemViewModel != null)
            {
                lineItemViewModel.ShippingAddressId = param.RecurringOrderLineItem.ShippingAddressId;
                vm.RecurringOrderTemplateLineItemViewModels.Add(lineItemViewModel);
            }

            return(vm);
        }
예제 #2
0
        protected virtual async Task <RecurringOrderTemplateViewModel> CreateTemplateDetailsViewModelAsync(CreateRecurringOrderTemplateDetailsViewModelParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (param.RecurringOrderLineItem == null)
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage(nameof(param.RecurringOrderLineItem)), nameof(param));
            }

            param.ProductImageInfo = new ProductImageInfo
            {
                ImageUrls = await ImageService.GetImageUrlsAsync(param.RecurringOrderLineItem).ConfigureAwait(false)
            };

            var methodDisplayNames = await LookupService.GetLookupDisplayNamesAsync(new GetLookupDisplayNamesParam
            {
                CultureInfo = param.CultureInfo,
                LookupType  = LookupType.Order,
                LookupName  = "PaymentMethodType",
            });

            param.PaymentMethodDisplayNames = methodDisplayNames;

            var vm = await RecurringOrderTemplateViewModelFactory.CreateRecurringOrderTemplateDetailsViewModel(param);

            return(vm);
        }