Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
        }