コード例 #1
0
        public void LoadInventoryForToday(string route, List <InitialInventoryLoadWithLot> initialInventoryLoadWithLots)
        {
            // Create new initial inventory header
            Models.InitialInventory initialInventory = new Models.InitialInventory
            {
                Route = route,
                SynchronizationDate = DateTime.Now,
                SynchronizationId   = CreateSynchronizationRecord(route, initialInventoryLoadWithLots.Count())
            };

            // Add new initial inventory to database context
            _context.InitialInventories.Add(initialInventory);

            // Save initial inventory to database
            _context.SaveChangesAsync();

            // Create initial inventory items
            CreateInitialInventoryItems(initialInventory, initialInventoryLoadWithLots);
        }
コード例 #2
0
        private void CreateInitialInventoryItems(Models.InitialInventory initialInventory, List <InitialInventoryLoadWithLot> initialInventoryLoadWithLots)
        {
            // Iterate through all initial inventory load with lots
            foreach (var initialInventoryLoadWithLot in initialInventoryLoadWithLots)
            {
                // Create new initial inventory item instance
                Models.InitialInventoryItem initialInventoryItem = new Models.InitialInventoryItem
                {
                    ItemCode           = initialInventoryLoadWithLot.ItemCode,
                    Lot                = initialInventoryLoadWithLot.Lot,
                    UnitsPerBox        = Int32.Parse(initialInventoryLoadWithLot.UnitsPerBox),
                    UnitsQuantity      = 1,
                    InitialInventoryId = initialInventory.Id
                };

                // Add new initial inventory item to database context
                _context.InitialInventoryItems.Add(initialInventoryItem);

                // Save initial inventory item to databases
                _context.SaveChangesAsync();
            }
        }