Exemplo n.º 1
0
        public static MOrder_AllocateOrderable MOrder_AllocateOrderable(MProject_ProjectSnapshot mProjectSnapshot)
        {
            var components = new List <MOrder_AllocateOrderableComponent>();

            foreach (var mProjectSnapshotComponent in mProjectSnapshot.Components)
            {
                components.Add(new MOrder_AllocateOrderableComponent()
                {
                    OrderableComponentReference = CreateOrderableCompnentReference.FromProjectSnapshotComponentId(mProjectSnapshotComponent.ProjectSnapshotComponentId),
                    Description = TextUtility.EncodeMultilineText(
                        mProjectSnapshotComponent.Sku,
                        mProjectSnapshotComponent.UnitOfMeasureName,
                        $"{mProjectSnapshotComponent.Manufacturer} - {mProjectSnapshotComponent.Collection} - {mProjectSnapshotComponent.Description}"),
                    ConsumableReference = mProjectSnapshotComponent.ConsumableReference,
                    Quantity            = mProjectSnapshotComponent.Quantity,
                    UnitPrice           = mProjectSnapshotComponent.UnitPrice,
                    TotalPrice          = mProjectSnapshotComponent.TotalPrice
                });
            }

            var result = new MOrder_AllocateOrderable()
            {
                OrderableReference = CreateOrderableReference.FromProjectSnapshotId(mProjectSnapshot.ProjectSnapshotId),
                Name       = $"{mProjectSnapshot.Name}",
                Price      = mProjectSnapshot.Price,
                Components = components
            };

            return(result);
        }
Exemplo n.º 2
0
        public async Task CreateOrder()
        {
            var logger = ServiceScope.ServiceProvider.GetService <ILogger <OrderTest> >();

            var ordererReference = CreateOrdererReference.FromTimestamp(GetUniqueNow());

            logger.LogInformation($"Orderer reference = {ordererReference}");

            var ordererId = await OrderMicroService.AllocateOrdererAsync(ordererReference);

            logger.LogInformation($"Orderer ID = {ordererId}");

            var orderableReference = CreateOrderableReference.FromTimestamp(GetUniqueNow());

            logger.LogInformation($"Orderable reference = {orderableReference}");

            var orderableComponentReference = CreateOrderableCompnentReference.FromTimestamp(GetUniqueNow());

            logger.LogInformation($"Orderable component reference = {orderableComponentReference}");

            var mAllocateOrderable = new MOrder_AllocateOrderable()
            {
                OrderableReference = orderableReference,
                Name       = "Orderable Item",
                Price      = 100,
                Components = new List <MOrder_AllocateOrderableComponent>()
                {
                    new MOrder_AllocateOrderableComponent()
                    {
                        OrderableComponentReference = orderableComponentReference,
                        Description         = "Orderable Item Component",
                        Quantity            = 2,
                        ConsumableReference = CreateConsumableReference.FromTimestamp(GetUniqueNow()),
                        UnitPrice           = 25,
                        TotalPrice          = 50
                    }
                }
            };

            var mAllocateOrderableResponse = await OrderMicroService.AllocateOrderableAsync(mAllocateOrderable);

            logger.LogInformation($"Orderable ID = {mAllocateOrderableResponse.OrderableId}");

            _ = await OrderMicroService.AddCartItemAsync(ordererId, mAllocateOrderableResponse.OrderableId, 2);

            logger.LogInformation("Item added to cart.");

            var shippingAddress = new MCommon_Address()
            {
                Name         = "RICHARD TODD",
                AddressLine1 = "17340 W 156 TER",
                City         = "OLATHE",
                StateCode    = "KS",
                PostalCode   = "66062",
                CountryCode  = "US"
            };

            _ = await OrderMicroService.UpdateShippingAddressAsync(ordererId, shippingAddress);

            logger.LogInformation("Shipping address updated.");

            var orderId = await OrderMicroService.SubmitCartAsync(ordererId);

            logger.LogInformation($"Order {orderId} submitted.");
        }