private void CheckInventory()
        {
            string warehouseCode = "Test";
            string entryCode     = "PriceTest_1";
            int    quantity      = 2;

            List <InventoryRequestItem> requestItems = new List <InventoryRequestItem>(); // holds the "items"
            InventoryRequestItem        requestItem  = new InventoryRequestItem();        // The one we use now

            requestItem.CatalogEntryCode = entryCode;
            requestItem.Quantity         = quantity;
            requestItem.WarehouseCode    = warehouseCode;
            requestItem.RequestType      = InventoryRequestType.Purchase; // reserve for now
            requestItems.Add(requestItem);

            InventoryRequest inventoryRequest =
                new InventoryRequest(DateTime.UtcNow, requestItems, null);
            InventoryResponse inventoryResponse = invSrvs.Service.Request(inventoryRequest);
            bool theBool = false;

            if (inventoryResponse.IsSuccess)
            {
                theBool = inventoryResponse.IsSuccess;
            }
            else
            {
                InventoryResponseItem     iii      = inventoryResponse.Items.FirstOrDefault();
                InventoryResponseTypeInfo typeInfo = iii.ResponseTypeInfo;
            }

            /*
             *
             *
             */
        }
Exemplo n.º 2
0
        public ActionResult CancelRequest(string code)
        {
            // use the "key" ... "WH-location", entry & Qty are irrelevant as the "key" governs what has happend
            // all are overlooked even if entered

            List <InventoryRequestItem> requestItems = new List <InventoryRequestItem>(); // holds the "items"
            InventoryRequestItem        requestItem  = new InventoryRequestItem();

            // calls for some logic
            requestItem.RequestType  = InventoryRequestType.Cancel; //
            requestItem.OperationKey = TempData["key"] as string;

            requestItems.Add(requestItem);

            InventoryRequest  inventoryRequest  = new InventoryRequest(DateTime.UtcNow, requestItems, null);
            InventoryResponse inventoryResponse = inventoryService.Service.Request(inventoryRequest);

            return(RedirectToAction("Index", "Variation"));

            // Check the "Complete-method"
            // ...no time-limited reservation (allthough it´s a custom implementation of "the provider")
            // ......could do a work-around with a timer counting down... and then cancel in code
        }
        //Injected<IOrderGroupFactory> _ogf;
        public ActionResult RequestInventory(string code) // step through this
        {
            // from Fund, maybe not what we want - heve more in Tran-Scope in CheckOutController
            //IOrderGroup c = _orderRepository.Create<ICart>(""); //
            //c.AdjustInventoryOrRemoveLineItems();
            //c.UpdateInventoryOrRemoveLineItems()

            // Get the WH
            string warehouseCode = "Nashua"; // a bit hard-coded
            //string warehouseCode = "Stocholm"; // a bit hard-coded here too

            // somewhat hard-coded...  no "Loader" though
            // could of course get info from the Market--> Country --> City etc.
            string warehouseCode2 = _warehouseRepository.List()
                                    .Where(w => w.ContactInformation.City == "Nashua")
                                    .First().Code;

            // can get several, should have some Geo-LookUp or alike to get the nearest WH
            IEnumerable <string> www = GetLocalMarketWarehouses();

            // Get the actual record in focus
            InventoryRecord inventoryRecord = _inventoryService.Get(code, warehouseCode);

            // could have some decisions made by the following props... just havinga look here
            decimal available          = inventoryRecord.PurchaseAvailableQuantity;
            decimal requested          = inventoryRecord.PurchaseRequestedQuantity;
            decimal backOrderAvailable = inventoryRecord.BackorderAvailableQuantity;
            decimal backOrderRequested = inventoryRecord.BackorderRequestedQuantity;

            List <InventoryRequestItem> requestItems = new List <InventoryRequestItem>(); // holds the "items"
            InventoryRequestItem        requestItem  = new InventoryRequestItem();        // The one we use now

            requestItem.CatalogEntryCode = code;
            requestItem.Quantity         = 3M;
            requestItem.WarehouseCode    = warehouseCode;
            // ...no time-out ootb --> custom coding... like for consert tickets

            // calls for some logic
            requestItem.RequestType = InventoryRequestType.Purchase; // reserve for now

            requestItems.Add(requestItem);

            InventoryRequest inventoryRequest =
                new InventoryRequest(DateTime.UtcNow, requestItems, null);
            InventoryResponse inventoryResponse = _inventoryService.Request(inventoryRequest);

            // pseudo-code for the "key" below
            //requestItem.OperationKey = requestItem.WarehouseCode + requestItem.CatalogEntryCode + requestItem.Quantity.ToString();

            if (inventoryResponse.IsSuccess)
            {
                TempData["key"] = inventoryResponse.Items[0].OperationKey; // bad place, just for demo
                // Storage is prepared in [dbo].[Shipment] ... or done "custom"
                // [OperationKeys] NVARCHAR (MAX)   NULL,
                // methods for management sits on the Shipment
                //      Serialized, InMemory and OldSchool
            }
            else
            {
                // could start to adjust Pre/Back-Order-qty
                InventoryRequestItem backOrderRequestItem = new InventoryRequestItem();
                backOrderRequestItem.CatalogEntryCode = code;
                backOrderRequestItem.Quantity         = 3M;
                backOrderRequestItem.WarehouseCode    = warehouseCode;
                backOrderRequestItem.RequestType      = InventoryRequestType.Backorder; // ...if enabled
                //Metadata below
                //backOrderRequestItem.OperationKey = backOrderRequestItem.RequestType + backOrderRequestItem.WarehouseCode + backOrderRequestItem.CatalogEntryCode + backOrderRequestItem.Quantity.ToString();

                List <InventoryRequestItem> backOrderRequestItems = new List <InventoryRequestItem>(); // holds the "items"
                backOrderRequestItems.Add(backOrderRequestItem);

                InventoryRequest backOrderRequest = new InventoryRequest(DateTime.UtcNow, backOrderRequestItems, null);

                InventoryResponse backOrderInventoryResponse =
                    _inventoryService.Request(backOrderRequest);
            }

            // dbo.InventoryService - table gets the requests and accumulate
            // inventoryService.Service.Request(requestItem);
            // and it increases in reserved until you can´t reserve more --> "Not Success"

            return(RedirectToAction("Index", "Variation"));
        }
Exemplo n.º 4
0
        public ActionResult RequestInventory(string code) // step through this
        {
            string warehouseCode = "Stockholm";           // a bit hard-coded
            //string warehouseCode = "Nashua"; // a bit hard-coded

            InventoryRecord inventoryRecord    = inventoryService.Service.Get(code, warehouseCode);
            decimal         available          = inventoryRecord.PurchaseAvailableQuantity;
            decimal         requested          = inventoryRecord.PurchaseRequestedQuantity;
            decimal         backOrderAvailable = inventoryRecord.BackorderAvailableQuantity;
            decimal         backOrderRequested = inventoryRecord.BackorderRequestedQuantity;

            List <InventoryRequestItem> requestItems = new List <InventoryRequestItem>(); // holds the "items"
            InventoryRequestItem        requestItem  = new InventoryRequestItem();

            requestItem.CatalogEntryCode = code;
            requestItem.Quantity         = 3M;
            // ...no time-out --> custom

            // calls for some logic
            requestItem.WarehouseCode = warehouseCode;
            requestItem.RequestType   = InventoryRequestType.Purchase; // reserve for now

            // pseudo-code below
            //requestItem.OperationKey = requestItem.WarehouseCode + requestItem.CatalogEntryCode + requestItem.Quantity.ToString();

            requestItems.Add(requestItem);

            InventoryRequest  inventoryRequest  = new InventoryRequest(DateTime.UtcNow, requestItems, null);
            InventoryResponse inventoryResponse = inventoryService.Service.Request(inventoryRequest);

            if (inventoryResponse.IsSuccess)
            {
                TempData["key"] = inventoryResponse.Items[0].OperationKey; // bad place, just for demo
                // Storage in [dbo].[Shipment]  or "custom"
                // [OperationKeys] NVARCHAR (MAX)   NULL,
            }
            else
            {
                // could start to adjust Pre/Back-Order-qty
                InventoryRequestItem backOrderRequestItem = new InventoryRequestItem();
                backOrderRequestItem.CatalogEntryCode = code;
                backOrderRequestItem.Quantity         = 3M;
                backOrderRequestItem.WarehouseCode    = warehouseCode;
                backOrderRequestItem.RequestType      = InventoryRequestType.Backorder; // ...if enabled
                backOrderRequestItem.OperationKey     = backOrderRequestItem.RequestType + backOrderRequestItem.WarehouseCode + backOrderRequestItem.CatalogEntryCode + backOrderRequestItem.Quantity.ToString();

                List <InventoryRequestItem> backOrderRequestItems = new List <InventoryRequestItem>(); // holds the "items"
                backOrderRequestItems.Add(backOrderRequestItem);

                InventoryRequest backOrderRequest = new InventoryRequest(DateTime.UtcNow, backOrderRequestItems, null);

                InventoryResponse backOrderInventoryResponse =
                    inventoryService.Service.Request(backOrderRequest); //
            }

            // ...gets
            //dbo.InventoryService - table gets the requests and accumulate

            //inventoryService.Service.Request(requestItem);
            // request it...
            // and it increases in reserved until you can´t reserve more --> "!Success"
            // ...and decreases available

            return(RedirectToAction("Index", "Variation"));
        }