public override void Synchronize(Func <LotKey> getInput)
        {
            if (getInput == null)
            {
                throw new ArgumentNullException("getInput");
            }
            var lotKey = getInput();

            var oldLot    = new SyncLotHelper(OldContext, UnitOfWork, OldContextHelper).SynchronizeOldLot(lotKey, false, false);
            var inventory = UnitOfWork.InventoryRepository
                            .Filter(i => i.LotDateCreated == lotKey.LotKey_DateCreated && i.LotDateSequence == lotKey.LotKey_DateSequence && i.LotTypeId == lotKey.LotKey_LotTypeId,
                                    i => i.PackagingProduct.Product,
                                    i => i.Location,
                                    i => i.Treatment)
                            .ToList();

            foreach (var item in inventory)
            {
                OldContext.tblIncomings.AddObject(CreateIncoming(oldLot, item));
            }

            OldContext.SaveChanges();

            Console.Write(ConsoleOutput.ReceivedInventory, oldLot.Lot);
        }
Пример #2
0
        public override void Synchronize(Func <SynchronizeLotParameters> getInput)
        {
            if (getInput == null)
            {
                throw new ArgumentNullException("getInput");
            }
            var parameters = getInput();

            var syncLotHelper = new SyncLotHelper(OldContext, UnitOfWork, OldContextHelper);

            var oldLots = parameters.LotKeys.Select(lotKey =>
            {
                var oldLot         = syncLotHelper.SynchronizeOldLot(lotKey, parameters.OverrideOldContextLotAsCompleted, parameters.UpdateSerializationOnly);
                parameters.LotStat = oldLot.LotStat;
                parameters.Notes   = oldLot.Notes;
                return(oldLot);
            })
                          .ToList();

            OldContext.SaveChanges();

            Console.Write(ConsoleOutput.UpdatedLot, string.Join(", ", oldLots.Select(l => l.Lot)));
        }