/// <summary> /// Gets the <see cref="EditAddressViewModel"/> to display the edit address From or Form result /// </summary> /// <param name="param">Builder params <see cref="GetEditAddressViewModelParam"/></param> /// <returns></returns> protected virtual async Task <EditAddressViewModel> GetEditAddressViewModel(GetEditAddressViewModelParam param) { if (param == null) { throw new ArgumentNullException("param"); } if (param.CultureInfo == null) { throw new ArgumentException("param.CultureInfo"); } var countryParam = new RetrieveCountryParam { CultureInfo = param.CultureInfo ?? ComposerContext.CultureInfo, IsoCode = ComposerContext.CountryCode }; var viewModel = ViewModelMapper.MapTo <EditAddressViewModel>(param.Address, param.CultureInfo) ?? new EditAddressViewModel(); viewModel.Status = param.Status.HasValue ? param.Status.Value.ToString() : string.Empty; viewModel.ReturnUrl = param.ReturnUrl; viewModel.IsUpdating = param.Address != null && param.IsUpdating; var country = await CountryService.RetrieveCountryAsync(countryParam).ConfigureAwait(false); if (country != null) { viewModel.PostalCodeRegex = country.PostalCodeRegex; viewModel.PhoneRegex = country.PhoneRegex; } return(viewModel); }
/// <summary> /// Gets the <see cref="AddressListViewModel"/> to display a list of addresses in MyAddresses Form or Form result /// </summary> /// <param name="param"></param> /// <param name="customer"></param> /// <param name="addresses"></param> /// <param name="regions"></param> /// <returns></returns> protected virtual AddressListViewModel GetAddressListViewModel( GetAddressListViewModelParam param, Customer customer, IEnumerable <Address> addresses, IEnumerable <RegionViewModel> regions) { var viewModel = ViewModelMapper.MapTo <AddressListViewModel>(customer, param.CultureInfo); viewModel.AddAddressUrl = param.AddAddressUrl; viewModel.Addresses = addresses.Select(address => { var addressVm = ViewModelMapper.MapTo <AddressListItemViewModel>(address, param.CultureInfo); var editUrlWithParam = UrlFormatter.AppendQueryString(param.EditAddressBaseUrl, new NameValueCollection { { "addressId", address.Id.ToString() } }); addressVm.UpdateAddressUrl = editUrlWithParam; var region = regions.FirstOrDefault(x => x.IsoCode == address.RegionCode); addressVm.RegionName = region != null ? region.Name : string.Empty; return(addressVm); }).ToList(); return(viewModel); }
/// <summary> /// Get the view Model to display the Sign In Header /// </summary> /// <returns> /// The view model to display the Sign In Header /// </returns> public virtual async Task <SignInHeaderViewModel> GetSignInHeaderModel(GetSignInHeaderParam param) { var myAccountUrl = MyAccountUrlProvider.GetMyAccountUrl(new BaseUrlParameter { CultureInfo = param.CultureInfo }); var loginUrl = MyAccountUrlProvider.GetLoginUrl(new BaseUrlParameter { CultureInfo = param.CultureInfo }); var customer = await CustomerRepository.GetCustomerByIdAsync(new GetCustomerByIdParam { CultureInfo = param.CultureInfo, CustomerId = param.CustomerId, Scope = param.Scope }).ConfigureAwait(false); var viewModel = ViewModelMapper.MapTo <SignInHeaderViewModel>(customer, param.CultureInfo) ?? new SignInHeaderViewModel(); viewModel.IsLoggedIn = param.IsAuthenticated; viewModel.EncryptedCustomerId = param.EncryptedCustomerId; viewModel.Url = viewModel.IsLoggedIn ? myAccountUrl : loginUrl; return(viewModel); }
protected virtual OrderShippingMethodViewModel GetShippingMethodViewModel(Shipment shipment, CreateOrderDetailViewModelParam param) { if (param.Order.Cart.Shipments == null) { throw new ArgumentNullException("param.Order.Cart.Shipments"); } if (shipment == null) { return(new OrderShippingMethodViewModel()); } var shippingMethodVm = ViewModelMapper.MapTo <OrderShippingMethodViewModel>(shipment.FulfillmentMethod, param.CultureInfo); if (param.Order.Cart.FulfillmentCost == 0) { var freeLabel = LocalizationProvider.GetLocalizedString(new GetLocalizedParam { Category = "ShoppingCart", Key = "L_Free", CultureInfo = param.CultureInfo }); shippingMethodVm.Cost = freeLabel; } shippingMethodVm.Taxable = shipment.IsShippingTaxable(); return(shippingMethodVm); }
public virtual StoreViewModel CreateStoreViewModel(CreateStoreViewModelParam param) { var store = param.Store; var storeViewModel = ViewModelMapper.MapTo <StoreViewModel>(store, param.CultureInfo); storeViewModel.Address = CreateStoreAddressViewModel(param); storeViewModel.LocalizedDisplayName = GetStoreLocalizedDisplayName(storeViewModel, param.CultureInfo); storeViewModel.FulfillmentLocationId = store.FulfillmentLocation.Id; storeViewModel.GoogleDirectionsLink = GetGoogleDirectionsLink(storeViewModel.Address); storeViewModel.GoogleStaticMapUrl = GetGoogleStaticMapUrl(storeViewModel.Address); storeViewModel.Url = StoreUrlProvider.GetStoreUrl(new GetStoreUrlParam() { BaseUrl = param.BaseUrl, CultureInfo = param.CultureInfo, StoreNumber = store.Number, StoreName = storeViewModel.Name }); if (param.SearchPoint != null && storeViewModel.Address.Latitude != null && storeViewModel.Address.Longitude != null) { storeViewModel.DestinationToSearchPoint = Math.Round(GeoCodeCalculator.CalcDistance( storeViewModel.Address.Latitude.Value, storeViewModel.Address.Longitude.Value, param.SearchPoint.Lat, param.SearchPoint.Lng, EarthRadiusMeasurement.Kilometers), 2); } storeViewModel.Schedule = CreateStoreScheduleViewModel(param); return(storeViewModel); }
/// <summary> /// Build an enumerable of images applicable to the current Product / Variant. /// </summary> /// <param name="productId">Id of the product.</param> /// <param name="variantId">Id of the Variant.</param> /// <param name="productImages">Images of all products being mapped.</param> /// <param name="cultureInfo">Culture Info.</param> /// <returns></returns> protected virtual IEnumerable <ProductDetailImageViewModel> BuildImages( string productId, string variantId, string defaultAlt, IEnumerable <AllProductImages> productImages, CultureInfo cultureInfo) { if (productImages == null) { return(Enumerable.Empty <ProductDetailImageViewModel>()); } var images = productImages .Where(pi => string.Equals(pi.ProductId, productId, StringComparison.InvariantCultureIgnoreCase)) .Where(pi => string.Equals(pi.VariantId, variantId, StringComparison.InvariantCultureIgnoreCase)) .OrderBy(pi => pi.SequenceNumber) .Select(pi => { var image = ViewModelMapper.MapTo <ProductDetailImageViewModel>(pi, cultureInfo); if (string.IsNullOrEmpty(image.Alt)) { image.Alt = defaultAlt; } return(image); }).ToList(); if (!images.Any(image => image.Selected)) { SetFirstImageSelected(images); } return(images); }
protected virtual List <CompleteCheckoutLineItemViewModel> MapCompleteCheckoutLineItems(Overture.ServiceModel.Orders.Order order, CultureInfo cultureInfo) { var lineItems = order.Cart.GetLineItems().Select(li => { var viewModel = ViewModelMapper.MapTo <CompleteCheckoutLineItemViewModel>(li, cultureInfo); var brandProperty = li.ProductSummary.Brand ?? string.Empty; var brand = string.IsNullOrWhiteSpace(brandProperty) ? string.Empty : LookupService.GetLookupDisplayNameAsync(new GetLookupDisplayNameParam { Delimiter = ", ", LookupName = "Brand", LookupType = LookupType.Product, Value = li.ProductSummary.Brand, CultureInfo = cultureInfo }).Result; viewModel.Name = li.ProductSummary.DisplayName; viewModel.BrandId = brandProperty; viewModel.Brand = brand; viewModel.CategoryId = li.ProductSummary.PrimaryParentCategoryId; viewModel.KeyVariantAttributesList = LineItemViewModelFactory.GetKeyVariantAttributes(new GetKeyVariantAttributesParam { KvaValues = li.KvaValues, KvaDisplayValues = li.KvaDisplayValues }).ToList(); return(viewModel); }); return(lineItems.ToList()); }
/// <summary> /// Gets the <see cref="AccountHeaderViewModel"/> to greet a given Customer. /// </summary> /// <param name="param">Builder params <see cref="GetAccountHeaderViewModelParam"/></param> /// <returns></returns> public async virtual Task <AccountHeaderViewModel> GetAccountHeaderViewModelAsync(GetAccountHeaderViewModelParam param) { if (param == null) { throw new ArgumentNullException(nameof(param)); } if (param.CultureInfo == null) { throw new ArgumentException(GetMessageOfNull(nameof(param.CultureInfo)), nameof(param)); } if (param.CustomerId == Guid.Empty) { throw new ArgumentException(GetMessageOfEmpty(nameof(param.CustomerId)), nameof(param)); } if (string.IsNullOrWhiteSpace(param.Scope)) { throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param)); } var customer = await CustomerRepository.GetCustomerByIdAsync(new GetCustomerByIdParam { CultureInfo = param.CultureInfo, CustomerId = param.CustomerId, Scope = param.Scope }).ConfigureAwait(false); var accountHeaderViewModel = ViewModelMapper.MapTo <AccountHeaderViewModel>(customer, param.CultureInfo); return(accountHeaderViewModel); }
protected virtual async Task <ProductSearchViewModel> CreateProductSearchViewModelAsync(ProductDocument productDocument, CreateProductSearchResultsViewModelParam <TParam> createSearchViewModelParam, IDictionary <Tuple <string, string>, ProductMainImage> imgDictionary) { var cultureInfo = createSearchViewModelParam.SearchParam.Criteria.CultureInfo; string variantId = null; if (productDocument.PropertyBag.ContainsKey(VariantPropertyBagKey)) { variantId = productDocument.PropertyBag[VariantPropertyBagKey] as string; } var productSearchVm = ViewModelMapper.MapTo <ProductSearchViewModel>(productDocument, cultureInfo); productSearchVm.BrandId = ExtractLookupId("Brand_Facet", productDocument.PropertyBag); MapProductSearchViewModelInfos(productSearchVm, productDocument, cultureInfo); MapProductSearchViewModelUrl(productSearchVm, variantId, cultureInfo, createSearchViewModelParam.SearchParam.Criteria.BaseUrl); MapProductSearchViewModelImage(productSearchVm, imgDictionary); productSearchVm.IsAvailableToSell = await GetProductSearchViewModelAvailableForSell(productSearchVm, productDocument).ConfigureAwait(false); productSearchVm.Pricing = await PriceProvider.GetPriceAsync(productSearchVm.HasVariants, productDocument).ConfigureAwait(false); productSearchVm.IsEligibleForRecurring = RecurringOrdersSettings.Enabled && productDocument.PropertyBag.IsEligibleForRecurring(); productSearchVm.Context["IsEligibleForRecurring "] = productSearchVm.IsEligibleForRecurring; return(productSearchVm); }
protected virtual MonerisAddVaultProfileViewModel MapModelToViewModel(VaultProfileCreationResult model, CultureInfo cultureInfo) { var vm = ViewModelMapper.MapTo <MonerisAddVaultProfileViewModel>(model, cultureInfo); vm.ActivePayment = MapActivePayment(model.UpdatedPayment, cultureInfo); return(vm); }
protected virtual IEnumerable <AdditionalFeeViewModel> MapLineItemAdditionalFeeViewModel(LineItem lineItem, CultureInfo cultureInfo) { if (lineItem.AdditionalFees == null) { yield break; } foreach (var lineItemAdditionalFee in lineItem.AdditionalFees) { var additionalFeeViewModel = ViewModelMapper.MapTo <AdditionalFeeViewModel>(lineItemAdditionalFee, cultureInfo); switch (lineItemAdditionalFee.CalculationRule) { case AdditionalFeeCalculationRule.PerUnit: additionalFeeViewModel.TotalAmount = lineItemAdditionalFee.Amount * (decimal)lineItem.Quantity; break; case AdditionalFeeCalculationRule.PerLineItem: additionalFeeViewModel.TotalAmount = lineItemAdditionalFee.Amount; break; } yield return(additionalFeeViewModel); } }
public virtual async Task <CurrencyViewModel> GetScopeCurrencyAsync(GetScopeCurrencyParam param) { if (param == null) { throw new ArgumentNullException(nameof(param)); } if (string.IsNullOrWhiteSpace(param.Scope)) { throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param)); } if (param.CultureInfo == null) { throw new ArgumentException(GetMessageOfNull(nameof(param.CultureInfo)), nameof(param)); } var p = new GetScopeParam { Scope = param.Scope }; var scope = await ScopeRepository.GetScopeAsync(p).ConfigureAwait(false); CurrencyViewModel vm = null; if (scope?.Currency != null) { vm = ViewModelMapper.MapTo <CurrencyViewModel>(scope.Currency, param.CultureInfo); } return(vm); }
protected virtual LightLineItemDetailViewModel GetLightLineItemDetailViewModel(CreateLineItemDetailViewModelParam param) { param.PreMapAction.Invoke(param.LineItem); var lineItem = param.LineItem; var vm = ViewModelMapper.MapTo <LightLineItemDetailViewModel>(lineItem, param.CultureInfo); if (vm.IsValid == null) { vm.IsValid = true; } ProductMainImage mainImage; if (param.ImageDictionary.TryGetValue(Tuple.Create(lineItem.ProductId, lineItem.VariantId), out mainImage)) { vm.ImageUrl = mainImage.ImageUrl; vm.FallbackImageUrl = mainImage.FallbackImageUrl; } vm.ProductUrl = ProductUrlProvider.GetProductUrl(new GetProductUrlParam { CultureInfo = param.CultureInfo, VariantId = lineItem.VariantId, ProductId = lineItem.ProductId, ProductName = lineItem.ProductSummary.DisplayName, SKU = lineItem.Sku }); return(vm); }
public virtual LineItemDetailViewModel GetLineItemDetailViewModel(CreateLineItemDetailViewModelParam param) { if (param.PreMapAction != null) { param.PreMapAction.Invoke(param.LineItem); } var lineItem = param.LineItem; var vm = ViewModelMapper.MapTo <LineItemDetailViewModel>(lineItem, param.CultureInfo); if (vm.IsValid == null) { vm.IsValid = true; } vm.Rewards = RewardViewModelFactory.CreateViewModel(lineItem.Rewards, param.CultureInfo, RewardLevel.LineItem).ToList(); vm.IsOnSale = lineItem.CurrentPrice.HasValue && lineItem.DefaultPrice.HasValue && (int)(lineItem.CurrentPrice.Value * 100) < (int)(lineItem.DefaultPrice.Value * 100); vm.IsPriceDiscounted = lineItem.DiscountAmount.GetValueOrDefault(0) > 0; decimal lineItemsSavingSale = Math.Abs(decimal.Multiply( decimal.Subtract( lineItem.CurrentPrice.GetValueOrDefault(0), lineItem.DefaultPrice.GetValueOrDefault(0)), Convert.ToDecimal(lineItem.Quantity))); decimal lineItemsSavingTotal = decimal.Add(lineItem.DiscountAmount.GetValueOrDefault(0), lineItemsSavingSale); vm.SavingsTotal = lineItemsSavingTotal.Equals(0) ? string.Empty : LocalizationProvider.FormatPrice(lineItemsSavingTotal, CurrencyProvider.GetCurrency()); vm.KeyVariantAttributesList = GetKeyVariantAttributes(new GetKeyVariantAttributesParam { KvaValues = lineItem.KvaValues, KvaDisplayValues = lineItem.KvaDisplayValues }).ToList(); if (param.ImageDictionary.TryGetValue((lineItem.ProductId, lineItem.VariantId), out ProductMainImage mainImage)) { vm.ImageUrl = mainImage.ImageUrl; vm.FallbackImageUrl = mainImage.FallbackImageUrl; } vm.ProductUrl = ProductUrlProvider.GetProductUrl(new GetProductUrlParam { CultureInfo = param.CultureInfo, VariantId = lineItem.VariantId, ProductId = lineItem.ProductId, ProductName = lineItem.ProductSummary.DisplayName, SKU = lineItem.Sku }); vm.AdditionalFees = MapLineItemAdditionalFeeViewModel(lineItem, param.CultureInfo).ToList(); //Because the whole class is not async, we call a .Result here _ = MapRecurringOrderFrequencies(vm, lineItem, param.CultureInfo).Result; return(vm); }
/// <summary> /// Generates the variant price model view item. /// </summary> /// <param name="cultureInfo"></param> /// <param name="variantPriceEntry">The variant price entry.</param> /// <returns></returns> protected virtual VariantPriceViewModel GenerateVariantPriceVm(CultureInfo cultureInfo, VariantPrice variantPriceEntry) { var vm = ViewModelMapper.MapTo <VariantPriceViewModel>(variantPriceEntry, cultureInfo); vm.IsPriceDiscounted = IsPriceDiscounted(variantPriceEntry.Pricing.Price, variantPriceEntry.DefaultPrice); vm.ListPrice = LocalizationProvider.FormatPrice(variantPriceEntry.Pricing.Price, cultureInfo); return(vm); }
/// <summary> /// Builds the compact order view model. /// </summary> /// <param name="rawOrder">The raw order.</param> /// <param name="param"></param> /// <returns></returns> protected virtual LightOrderDetailViewModel BuildLightOrderDetailViewModel(OrderItem rawOrder, GetOrderHistoryViewModelParam param) { var lightOrderVm = new LightOrderDetailViewModel(); var orderInfo = ViewModelMapper.MapTo <OrderDetailInfoViewModel>(rawOrder, param.CultureInfo); var orderId = Guid.Parse(rawOrder.Id); orderInfo.OrderStatus = GetOrderStatusDisplayName(rawOrder, param); orderInfo.OrderStatusRaw = rawOrder.OrderStatus; orderInfo.IsOrderEditable = param.OrderEditingInfos != null && param.OrderEditingInfos.ContainsKey(orderId) && param.OrderEditingInfos[orderId]; CancellationStatus orderCancellationStatusInfo = null; if (param.OrderCancellationStatusInfos != null && param.OrderCancellationStatusInfos.ContainsKey(orderId)) { orderCancellationStatusInfo = param.OrderCancellationStatusInfos[orderId]; } orderInfo.IsOrderCancelable = orderCancellationStatusInfo?.CanCancel ?? false; orderInfo.IsOrderPendingCancellation = orderCancellationStatusInfo?.CancellationPending ?? false; orderInfo.IsBeingEdited = param.CurrentlyEditedOrderId == orderId; orderInfo.HasOwnDraft = HasOwnDraft(param, orderId); var orderDetailUrl = UrlFormatter.AppendQueryString(param.OrderDetailBaseUrl, new NameValueCollection { { "id", rawOrder.OrderNumber } }); lightOrderVm.Url = orderDetailUrl; lightOrderVm.OrderInfos = orderInfo; lightOrderVm.ShipmentSummaries = new List <OrderShipmentSummaryViewModel>(); if (rawOrder.ShipmentItems.Count > 0) { foreach (var shipment in rawOrder.ShipmentItems) { var shipmentSummary = new OrderShipmentSummaryViewModel(); if (shipment.FulfillmentScheduledTimeBeginDate.HasValue) { shipmentSummary.ScheduledShipDate = LocalizationHelper.LocalizedFormat("General", "ShortDateFormat", shipment.FulfillmentScheduledTimeBeginDate.Value, param.CultureInfo); } if (param.ShipmentsTrackingInfos != null && param.ShipmentsTrackingInfos.ContainsKey(shipment.Id)) { var trackingInfo = param.ShipmentsTrackingInfos[shipment.Id]; shipmentSummary.TrackingInfo = trackingInfo; } lightOrderVm.ShipmentSummaries.Add(shipmentSummary); } } return(lightOrderVm); }
protected virtual UpdateAccountViewModel GetUpdateAccountViewModel(GetUpdateAccountViewModelParam param, Customer customer) { var viewModel = ViewModelMapper.MapTo <UpdateAccountViewModel>(customer, param.CultureInfo); viewModel.Status = param.Status.HasValue ? param.Status.Value.ToString("G") : string.Empty; viewModel.ReturnUrl = param.ReturnUrl; viewModel.Languages = GetPreferredLanguageViewModel(param.CultureInfo, customer.Language); return(viewModel); }
/// <summary> /// Creates the model view product price. /// </summary> /// <param name="cultureInfo">The get product price parameter.</param> /// <param name="productPrice">The product price.</param> /// <returns></returns> protected virtual ProductPriceViewModel GenerateProductPriceVm(CultureInfo cultureInfo, ProductPrice productPrice) { var vm = ViewModelMapper.MapTo <ProductPriceViewModel>(productPrice, cultureInfo); vm.IsPriceDiscounted = IsPriceDiscounted(productPrice.Pricing.Price, productPrice.DefaultPrice); vm.ListPrice = LocalizationProvider.FormatPrice(productPrice.Pricing.Price, cultureInfo); vm.VariantPrices = new List <VariantPriceViewModel>(); return(vm); }
public virtual RecurringOrderShippingMethodViewModel GetShippingMethodViewModel(FulfillmentMethodInfo fulfillmentMethodInfo, CultureInfo cultureInfo) { if (fulfillmentMethodInfo == null) { return(null); } var shippingMethodViewModel = ViewModelMapper.MapTo <RecurringOrderShippingMethodViewModel>(fulfillmentMethodInfo, cultureInfo); return(shippingMethodViewModel); }
protected virtual void MapCustomer(CustomerSummary customer, CultureInfo cultureInfo, CartViewModel cartVm) { if (customer == null) { return; } var customerViewModel = ViewModelMapper.MapTo <CustomerSummaryViewModel>(customer, cultureInfo); cartVm.Customer = customerViewModel; }
protected virtual CouponViewModel MapCoupon(Coupon coupon, Reward reward, CultureInfo cultureInfo) { var vm = ViewModelMapper.MapTo <CouponViewModel>(coupon, cultureInfo); if (reward != null) { vm.Amount = reward.Amount; vm.PromotionName = reward.PromotionName; } return(vm); }
/// <summary> /// Get the view Model to display a Change Password Form and Form result /// </summary> /// <param name="param">Builder params <see cref="GetChangePasswordViewModelParam"/></param> /// <returns> /// The view model to display the Change Password Form /// </returns> protected virtual ChangePasswordViewModel GetChangePasswordViewModel(GetChangePasswordViewModelParam param) { var viewModel = param.Customer != null ? ViewModelMapper.MapTo <ChangePasswordViewModel>(param.Customer, param.CultureInfo) : new ChangePasswordViewModel(); viewModel.Status = param.Status.HasValue ? param.Status.Value.ToString("G") : string.Empty; viewModel.ReturnUrl = param.ReturnUrl; SetPasswordValidationRules(viewModel); return(viewModel); }
public virtual RecurringOrderProgramViewModel CreateRecurringOrderProgramViewModel(RecurringOrderProgram program, CultureInfo culture) { if (program == null) { throw new ArgumentNullException(nameof(program)); } if (culture == null) { throw new ArgumentNullException(nameof(culture)); } var vm = ViewModelMapper.MapTo <RecurringOrderProgramViewModel>(program, culture); if (vm == null) { return(null); } var programLocalized = program.Localizations?.Find(l => string.Equals(l.CultureIso, culture.Name, StringComparison.OrdinalIgnoreCase)); if (programLocalized != null) { vm.DisplayName = programLocalized.DisplayName; if (program.Frequencies != null && program.Frequencies.Any()) { var dictionary = new Dictionary <string, RecurringOrderProgramFrequencyViewModel>(StringComparer.OrdinalIgnoreCase); foreach (var vmFrequency in vm.Frequencies) { if (dictionary.ContainsKey(vmFrequency.RecurringOrderFrequencyName)) { continue; } dictionary.Add(vmFrequency.RecurringOrderFrequencyName, vmFrequency); } foreach (var frequency in program.Frequencies) { dictionary.TryGetValue(frequency.RecurringOrderFrequencyName, out RecurringOrderProgramFrequencyViewModel vmFrequency); if (vmFrequency != null) { var localizlocalizedFrequency = frequency.Localizations.Find(l => string.Equals(l.CultureIso, culture.Name, StringComparison.OrdinalIgnoreCase)); vmFrequency.DisplayName = localizlocalizedFrequency != null ? localizlocalizedFrequency.DisplayName : vmFrequency.RecurringOrderFrequencyName; } } } } vm.Frequencies = vm.Frequencies.OrderBy(f => f.SequenceNumber).ToList(); return(vm); }
public virtual SavedCreditCardPaymentMethodViewModel MapSavedCreditCard(PaymentMethod payment, CultureInfo cultureInfo) { var savedCreditCard = ViewModelMapper.MapTo <SavedCreditCardPaymentMethodViewModel>(payment, cultureInfo); if (!string.IsNullOrWhiteSpace(savedCreditCard.ExpiryDate)) { var expirationDate = ParseCreditCartExpiryDate(savedCreditCard.ExpiryDate); expirationDate = expirationDate.AddDays(DateTime.DaysInMonth(expirationDate.Year, expirationDate.Month) - 1); savedCreditCard.IsExpired = expirationDate < DateTime.UtcNow; } return(savedCreditCard); }
/// <summary> /// Retrieve the CountryViewModel /// </summary> /// <param name="param"></param> /// <returns></returns> public virtual async Task <CountryViewModel> RetrieveCountryAsync(RetrieveCountryParam param) { if (string.IsNullOrWhiteSpace(param.IsoCode)) { throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.IsoCode)), nameof(param)); } var country = await CountryRepository.RetrieveCountry(param).ConfigureAwait(false); var countryViewModel = ViewModelMapper.MapTo <CountryViewModel>(country, param.CultureInfo); return(countryViewModel); }
/// <summary> /// Get the view Model to display a Change Password Form and Form result /// </summary> /// <param name="param">Builder params <see cref="GetChangePasswordViewModelParam"/></param> /// <returns> /// The view model to display the Change Password Form /// </returns> protected virtual ChangePasswordViewModel GetChangePasswordViewModel(GetChangePasswordViewModelParam param) { var viewModel = param.Customer != null?ViewModelMapper.MapTo <ChangePasswordViewModel>(param.Customer, param.CultureInfo) : new ChangePasswordViewModel(); viewModel.Status = param.Status.HasValue ? param.Status.Value.ToString("G") : string.Empty; viewModel.MinRequiredPasswordLength = MembershipProvider.MinRequiredPasswordLength; viewModel.MinRequiredNonAlphanumericCharacters = MembershipProvider.MinRequiredNonAlphanumericCharacters; viewModel.PasswordRegexPattern = CreatePasswordRegexPattern().ToString(); viewModel.ReturnUrl = param.ReturnUrl; return(viewModel); }
/// <summary> /// Retrieve the CountryViewModel /// </summary> /// <param name="param"></param> /// <returns></returns> public virtual async Task <CountryViewModel> RetrieveCountryAsync(RetrieveCountryParam param) { if (string.IsNullOrWhiteSpace(param.IsoCode)) { throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("IsoCode"), "param"); } var country = await CountryRepository.RetrieveCountry(param).ConfigureAwait(false); var countryViewModel = ViewModelMapper.MapTo <CountryViewModel>(country, param.CultureInfo); return(countryViewModel); }
public virtual CartViewModel CreateCartViewModel(CreateCartViewModelParam param) { if (param == null) { throw new ArgumentNullException("param"); } if (param.CultureInfo == null) { throw new ArgumentNullException("CultureInfo"); } if (param.ProductImageInfo == null) { throw new ArgumentNullException("ProductImageInfo"); } if (param.ProductImageInfo.ImageUrls == null) { throw new ArgumentNullException("ImageUrls"); } if (string.IsNullOrWhiteSpace(param.BaseUrl)) { throw new ArgumentException("BaseUrl"); } var vm = ViewModelMapper.MapTo <CartViewModel>(param.Cart, param.CultureInfo); if (vm == null) { return(null); } vm.OrderSummary = GetOrderSummaryViewModel(param.Cart, param.CultureInfo); MapShipmentsAndPayments(param.Cart, param.CultureInfo, param.ProductImageInfo, param.BaseUrl, param.PaymentMethodDisplayNames, vm, param.Cart.Payments); MapCustomer(param.Cart.Customer, param.CultureInfo, vm); vm.Coupons = GetCouponsViewModel(param.Cart, param.CultureInfo, param.IncludeInvalidCouponsMessages); vm.OrderSummary.AdditionalFeeSummaryList = GetAdditionalFeesSummary(vm.LineItemDetailViewModels, param.CultureInfo); SetDefaultCountryCode(vm); SetPostalCodeRegexPattern(vm); SetPhoneNumberRegexPattern(vm); // Reverse the items order in the Cart so the last added item will be the first in the list if (vm.LineItemDetailViewModels != null) { vm.LineItemDetailViewModels.Reverse(); } vm.IsAuthenticated = ComposerContext.IsAuthenticated; return(vm); }
protected virtual List <DailyScheduleExceptionViewModel> GetOpeningHourExceptions(FulfillmentSchedule schedule, CultureInfo cultureInfo, DateTime today) { var exceptions = StoreScheduleProvider.GetOpeningHourExceptions(schedule, today, 1); return(exceptions.Select( ex => ViewModelMapper.MapTo <DailyScheduleExceptionViewModel>(new { ex.StartDate, ex.EndDate, ex.IsClosed, OpeningTime = GetScheduleIntervalViewModel(ex.OpeningTime, cultureInfo) }, cultureInfo)) .ToList()); }
protected virtual List <DailyScheduleExceptionViewModel> GetOpeningHourExceptions(CreateStoreViewModelParam param, DateTime today) { var exceptions = StoreScheduleProvider.GetOpeningHourExceptions(param.Store.StoreSchedule, today, 1); return(exceptions.Select( ex => ViewModelMapper.MapTo <DailyScheduleExceptionViewModel>(new { ex.StartDate, ex.EndDate, ex.IsClosed, OpeningTime = GetScheduleIntervalViewModel(ex.OpeningTime, param.CultureInfo) }, param.CultureInfo)) .ToList()); }