示例#1
0
        private async Task <Dictionary <Guid, bool> > GetOrderEditingInfos(List <Overture.ServiceModel.Orders.Order> orders)
        {
            var orderEditingInfos = new Dictionary <Guid, bool>();

            foreach (var order in orders)
            {
                orderEditingInfos.Add(Guid.Parse(order.Id), await EditingOrderProvider.CanEdit(order).ConfigureAwait(false));
            }

            return(orderEditingInfos);
        }
示例#2
0
        private async Task <Dictionary <Guid, CancellationStatus> > GetCancellationStatus(List <Overture.ServiceModel.Orders.Order> orders)
        {
            var cancellationStatusInfo = new Dictionary <Guid, CancellationStatus>();

            foreach (var order in orders)
            {
                cancellationStatusInfo.Add(Guid.Parse(order.Id), await EditingOrderProvider.GetCancellationStatus(order).ConfigureAwait(false));
            }

            return(cancellationStatusInfo);
        }
示例#3
0
        protected virtual async Task <OrderDetailViewModel> BuildOrderDetailViewModelAsync(
            Overture.ServiceModel.Orders.Order order,
            GetOrderParam getOrderParam)
        {
            Helper.LineItemsHelper.PrepareGiftLineItems(order.Cart);

            var shipmentsNotes = await GetShipmentsNotes(order.Cart.Shipments, getOrderParam.Scope).ConfigureAwait(false);

            var orderChanges = await OrderRepository.GetOrderChangesAsync(new GetOrderChangesParam
            {
                OrderNumber = getOrderParam.OrderNumber,
                Scope       = getOrderParam.Scope
            }).ConfigureAwait(false);

            var orderCartDrafts = await GetOrderCartDrafts(getOrderParam.Scope, Guid.Parse(order.CustomerId), getOrderParam.CultureInfo).ConfigureAwait(false);

            var orderStatuses = await LookupService.GetLookupDisplayNamesAsync(new GetLookupDisplayNamesParam
            {
                CultureInfo = getOrderParam.CultureInfo,
                LookupType  = LookupType.Order,
                LookupName  = "OrderStatus",
            }).ConfigureAwait(false);

            var shipmentStatuses = await LookupService.GetLookupDisplayNamesAsync(new GetLookupDisplayNamesParam
            {
                CultureInfo = getOrderParam.CultureInfo,
                LookupType  = LookupType.Order,
                LookupName  = "ShipmentStatus",
            }).ConfigureAwait(false);

            var productImageInfo = new ProductImageInfo
            {
                ImageUrls = await ImageService.GetImageUrlsAsync(order.Cart.GetLineItems()).ConfigureAwait(false)
            };

            var viewModel = OrderDetailsViewModelFactory.CreateViewModel(new CreateOrderDetailViewModelParam
            {
                Order            = order,
                OrderChanges     = orderChanges,
                OrderStatuses    = orderStatuses,
                ShipmentStatuses = shipmentStatuses,
                CultureInfo      = getOrderParam.CultureInfo,
                CountryCode      = getOrderParam.CountryCode,
                ProductImageInfo = productImageInfo,
                BaseUrl          = getOrderParam.BaseUrl,
                ShipmentsNotes   = shipmentsNotes,
                OrderCartDrafts  = orderCartDrafts
            });

            viewModel.OrderInfos.IsOrderEditable = await EditingOrderProvider.CanEdit(order).ConfigureAwait(false);

            viewModel.OrderInfos.IsBeingEdited = EditingOrderProvider.IsBeingEdited(order);

            var orderCancellationStatus = await EditingOrderProvider.GetCancellationStatus(order).ConfigureAwait(false);

            viewModel.OrderInfos.IsOrderCancelable          = orderCancellationStatus.CanCancel;
            viewModel.OrderInfos.IsOrderPendingCancellation = orderCancellationStatus.CancellationPending;

            if (order.Cart.PropertyBag.TryGetValue("PickedItems", out var pickedItemsObject))
            {
                var pickedItemsList = ComposerJsonSerializer.Deserialize <List <PickedItemViewModel> >(pickedItemsObject.ToString());
                var shipment        = viewModel.Shipments.First();
                shipment.LineItems = await ProcessPickedLineItemsAsync(pickedItemsList, shipment.LineItems, getOrderParam.CultureInfo).ConfigureAwait(false);
            }
            ;

            return(viewModel);
        }
示例#4
0
        /// <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);
        }