/// <summary> /// Gets the OrderHistory ViewModel, containing a list of Orders. /// </summary> /// <param name="param"></param> /// <returns></returns> public virtual async Task <OrderHistoryViewModel> GetOrderHistoryViewModelAsync(GetCustomerOrdersParam param) { if (param == null) { throw new ArgumentNullException("param"); } if (param.CultureInfo == null) { throw new ArgumentException("param.CultureInfo"); } if (param.CustomerId == null) { throw new ArgumentException("param.CustomerId"); } if (string.IsNullOrWhiteSpace(param.Scope)) { throw new ArgumentException("param.Scope"); } var orderDetailBaseUrl = OrderUrlProvider.GetOrderDetailsBaseUrl(param.CultureInfo); var orderStatuses = await LookupService.GetLookupDisplayNamesAsync(new GetLookupDisplayNamesParam { CultureInfo = param.CultureInfo, LookupType = LookupType.Order, LookupName = "OrderStatus", }).ConfigureAwait(false); var orderQueryResult = await OrderRepository.GetCustomerOrdersAsync(param).ConfigureAwait(false); var shipmentsTrackingInfos = new Dictionary <Guid, TrackingInfoViewModel>(); if (orderQueryResult != null && orderQueryResult.Results != null && param.OrderTense == OrderTense.CurrentOrders) { shipmentsTrackingInfos = await GetShipmentsTrackingInfoViewModels(orderQueryResult, param).ConfigureAwait(false); } var getOrderHistoryViewModelParam = new GetOrderHistoryViewModelParam { CultureInfo = param.CultureInfo, OrderResult = orderQueryResult, OrderStatuses = orderStatuses, Page = param.Page, OrderDetailBaseUrl = orderDetailBaseUrl, ShipmentsTrackingInfos = shipmentsTrackingInfos }; var viewModel = OrderHistoryViewModelFactory.CreateViewModel(getOrderHistoryViewModelParam); return(viewModel); }
protected virtual async Task <CompleteCheckoutViewModel> MapOrderToCompleteCheckoutViewModel(Overture.ServiceModel.Orders.Order order, CompleteCheckoutParam param) { if (order == null) { return(null); } var orderStatuses = await LookupService.GetLookupDisplayNamesAsync(new GetLookupDisplayNamesParam { CultureInfo = param.CultureInfo, LookupType = LookupType.Order, LookupName = "OrderStatus", }).ConfigureAwait(false); var productImageInfo = new ProductImageInfo { ImageUrls = await ImageService.GetImageUrlsAsync(order.Cart.GetLineItems()).ConfigureAwait(false) }; var getVmOrderParam = new CreateOrderDetailViewModelParam { Order = order, CultureInfo = param.CultureInfo, OrderStatuses = orderStatuses, OrderDetailBaseUrl = OrderUrlProvider.GetOrderDetailsBaseUrl(param.CultureInfo), BaseUrl = param.BaseUrl, ProductImageInfo = productImageInfo, }; var orderViewModel = OrderDetailsViewModelFactory.CreateLightViewModel(getVmOrderParam); var completeCheckoutViewModel = new CompleteCheckoutViewModel { OrderNumber = order.OrderNumber, Order = orderViewModel, CustomerEmail = order.Cart.Customer.Email, CustomerFirstName = order.Cart.Customer.FirstName, CustomerLastName = order.Cart.Customer.LastName, Affiliation = order.Cart.OrderLocation?.Name, Revenu = order.Cart.Total, Tax = order.Cart.TaxTotal, Shipping = order.Cart.FulfillmentCost, ShippingOptions = order.Cart.Shipments?.FirstOrDefault()?.FulfillmentMethod.FulfillmentMethodType.ToString().ToLowerInvariant(), BillingCurrency = order.Cart.BillingCurrency, Coupons = MapCoupons(order, param.CultureInfo), LineItems = orderViewModel?.Shipments.FirstOrDefault()?.LineItems }; return(completeCheckoutViewModel); }
/// <summary> /// Gets the OrderHistory ViewModel, containing a list of Orders. /// </summary> /// <param name="param"></param> /// <returns></returns> public virtual async Task <OrderHistoryViewModel> GetOrderHistoryViewModelAsync(GetCustomerOrdersParam 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 == null) { throw new ArgumentException(GetMessageOfNull(nameof(param.CustomerId)), nameof(param)); } if (string.IsNullOrWhiteSpace(param.Scope)) { throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param)); } var orderQueryResult = await OrderRepository.GetCustomerOrdersAsync(param).ConfigureAwait(false); if (orderQueryResult == null) { return(null); } var orderDetailBaseUrl = OrderUrlProvider.GetOrderDetailsBaseUrl(param.CultureInfo); var orderStatuses = await LookupService.GetLookupDisplayNamesAsync(new GetLookupDisplayNamesParam { CultureInfo = param.CultureInfo, LookupType = LookupType.Order, LookupName = "OrderStatus", }).ConfigureAwait(false); var shipmentsTrackingInfos = new Dictionary <Guid, TrackingInfoViewModel>(); var ordersDetails = new List <Overture.ServiceModel.Orders.Order>(); var orderCartDrafts = new List <CartSummary>(); var orderEditingInfos = new Dictionary <Guid, bool>(); var orderCancellationInfos = new Dictionary <Guid, CancellationStatus>(); if (orderQueryResult.Results != null && param.OrderTense == OrderTense.CurrentOrders) { ordersDetails = await GetOrders(orderQueryResult, param).ConfigureAwait(false); orderCartDrafts = await GetOrderCartDrafts(param.Scope, param.CustomerId, param.CultureInfo).ConfigureAwait(false); orderEditingInfos = await GetOrderEditingInfos(ordersDetails).ConfigureAwait(false); orderCancellationInfos = await GetCancellationStatus(ordersDetails).ConfigureAwait(false); shipmentsTrackingInfos = GetShipmentsTrackingInfoViewModels(ordersDetails, param); } Guid.TryParse(EditingOrderProvider.GetCurrentEditingCartName(), out Guid currentlyEditingOrder); var getOrderHistoryViewModelParam = new GetOrderHistoryViewModelParam { CultureInfo = param.CultureInfo, OrderResult = orderQueryResult, OrderCartDrafts = orderCartDrafts, OrderStatuses = orderStatuses, Page = param.Page, OrderDetailBaseUrl = orderDetailBaseUrl, ShipmentsTrackingInfos = shipmentsTrackingInfos, OrderEditingInfos = orderEditingInfos, Orders = ordersDetails, OrderCancellationStatusInfos = orderCancellationInfos, CurrentlyEditedOrderId = currentlyEditingOrder }; var viewModel = OrderHistoryViewModelFactory.CreateViewModel(getOrderHistoryViewModelParam); return(viewModel); }