private Inventory CreateInventory(ViewInventoryLoadSelected inventory, ILotKey lotKey)
        {
            if (inventory.Quantity < 1)
            {
                Log(new CallbackParameters(CallbackReason.QuantityLessThanOne)
                {
                    Inventory = inventory
                });
                return(null);
            }

            var warehouseLocation = NewContextHelper.GetLocation(inventory.LocID);

            if (warehouseLocation == null)
            {
                Log(new CallbackParameters(CallbackReason.WarehouseLocationNotLoaded)
                {
                    Inventory = inventory
                });
                return(null);
            }

            var packagingProduct = GetInventoryPackaging(inventory);

            if (packagingProduct == null)
            {
                Log(new CallbackParameters(CallbackReason.PackagingNotLoaded)
                {
                    Inventory = inventory
                });
                return(null);
            }

            return(new Inventory
            {
                LotDateCreated = lotKey.LotKey_DateCreated,
                LotDateSequence = lotKey.LotKey_DateSequence,
                LotTypeId = lotKey.LotKey_LotTypeId,

                PackagingProductId = packagingProduct.Id,
                LocationId = warehouseLocation.Id,
                TreatmentId = inventory.TrtmtID,
                ToteKey = inventory.Tote ?? "",

                Quantity = (int)inventory.Quantity
            });
        }
 protected override IProduct GetInventoryPackaging(ViewInventoryLoadSelected inventory)
 {
     return(NewContextHelper.NoPackagingProduct.Product);
 }
        protected virtual IProduct GetInventoryPackaging(ViewInventoryLoadSelected inventory)
        {
            var lotPackaging = NewContextHelper.GetPackagingProduct(inventory.PkgID);

            return(lotPackaging != null ? lotPackaging.Product : null);
        }