コード例 #1
0
        private Lazy <IEnumerable <WarehouseInventoryViewModel> > GetAllWarehouseInventory(VariationContent catalogContent)
        {
            //make sure we don't get any null reference exception when accessing Inventories.
            var inventories           = Enumerable.Empty <Inventory>();
            var allWarehouseInventory = new List <WarehouseInventoryViewModel>();

            if (catalogContent != null && catalogContent.IsAvailableInCurrentMarket())
            {
                inventories = catalogContent.GetStockPlacement(InventoryLoader);
            }

            if (inventories.Count() > 0)
            {
                foreach (Inventory inventory in inventories)
                {
                    var warehouse = WarehouseHelper.GetWarehouse(inventory.WarehouseCode);
                    if (warehouse != null && warehouse.IsActive)
                    {
                        WarehouseInventoryViewModel model = new WarehouseInventoryViewModel()
                        {
                            WarehouseCode    = warehouse.Code,
                            WarehouseName    = HttpUtility.HtmlEncode(warehouse.Name),
                            WarehouseContact = HttpUtility.HtmlEncode(string.Format("{0} - {1}", warehouse.ContactInformation.FullName,
                                                                                    warehouse.ContactInformation.Email)),
                            WarehouseAddress = HttpUtility.HtmlEncode(string.Format("{0} {1}", warehouse.ContactInformation.Line1,
                                                                                    warehouse.ContactInformation.City))
                        };
                        model.InStockLevel  = inventory.InStockQuantity;
                        model.ReservedLevel = inventory.ReservedQuantity;
                        model.IsAvailable   = (inventory.InStockQuantity - inventory.ReservedQuantity > 0);

                        allWarehouseInventory.Add(model);
                    }
                }
            }

            return(new Lazy <IEnumerable <WarehouseInventoryViewModel> >(() => allWarehouseInventory));
        }
コード例 #2
0
        /// <summary>
        /// convert container part to warehouse inventory list model
        /// </summary>
        /// <param name="containerPart"></param>
        /// <returns></returns>
        public WarehouseInventoryViewModel ConvertToListView(ContainerPart containerPart)
        {
            WarehouseInventoryViewModel model = new WarehouseInventoryViewModel();

            var _foundryOrderRepository  = new FoundryOrderRepository();
            var _customerOrderRepository = new CustomerOrderRepository();
            var _partRepository          = new PartRepository();
            var _dynamicsPartRepository  = new PartDynamicsRepository();
            var _containerRepository     = new ContainerRepository();

            var foundryOrderPart  = _foundryOrderRepository.GetFoundryOrderPart(containerPart.FoundryOrderPartId);
            var customerOrderPart = _customerOrderRepository.GetCustomerOrderPart((foundryOrderPart != null) ? foundryOrderPart.CustomerOrderPartId : Guid.Empty);
            var part         = _partRepository.GetPart((foundryOrderPart != null) ? foundryOrderPart.PartId : Guid.Empty);
            var dynamicsPart = _dynamicsPartRepository.GetPartMaster((part != null) ? part.Number : string.Empty);
            var container    = _containerRepository.GetContainer(containerPart.ContainerId);

            model.CustomerId       = (part != null) ? part.CustomerId : "N/A";
            model.ShipCode         = (foundryOrderPart != null) ? foundryOrderPart.ShipCode : "N/A";
            model.PartNumber       = (part != null && !string.IsNullOrEmpty(part.Number)) ? part.Number : "N/A";
            model.PartWeight       = (dynamicsPart != null) ? (dynamicsPart.ITEMSHWT / 100.00m) : 0.00m;
            model.PalletNumber     = (!string.IsNullOrEmpty(part.Number)) ? containerPart.PalletNumber : "N/A";
            model.PalletQuantity   = containerPart.Quantity;
            model.TotalQuantity    = containerPart.Quantity;
            model.ContainerNumber  = (!string.IsNullOrEmpty(part.Number)) ? container.Number : "N/A";
            model.PONumber         = (customerOrderPart != null && !string.IsNullOrEmpty(customerOrderPart.CustomerOrder.PONumber)) ? customerOrderPart.CustomerOrder.PONumber : "N/A";
            model.WarehouseDate    = (foundryOrderPart != null) ? foundryOrderPart.ReceiptDate : DateTime.MinValue;
            model.WarehouseDateStr = (foundryOrderPart != null && foundryOrderPart.ReceiptDate != null) ? foundryOrderPart.ReceiptDate.Value.ToShortDateString() : "N/A";
            model.SixtyDaysDate    = (foundryOrderPart != null && foundryOrderPart.ReceiptDate != null) ? foundryOrderPart.ReceiptDate.Value.AddDays(60) : DateTime.MinValue;
            model.SixtyDaysDateStr = (model.SixtyDaysDate != null) ? model.SixtyDaysDate.Value.ToShortDateString() : "N/A";

            if (_foundryOrderRepository != null)
            {
                _foundryOrderRepository.Dispose();
                _foundryOrderRepository = null;
            }

            if (_customerOrderRepository != null)
            {
                _customerOrderRepository.Dispose();
                _customerOrderRepository = null;
            }

            if (_partRepository != null)
            {
                _partRepository.Dispose();
                _partRepository = null;
            }

            if (_dynamicsPartRepository != null)
            {
                _dynamicsPartRepository.Dispose();
                _dynamicsPartRepository = null;
            }

            if (_containerRepository != null)
            {
                _containerRepository.Dispose();
                _containerRepository = null;
            }

            return(model);
        }