private static void UpdateOldLot(tblLot oldLot, Lot newLot, Customer customer, bool completedOverride, bool updateSerializationOnly) { if (!updateSerializationOnly) { if (customer != null) { oldLot.Company_IA = customer.Company.Name; } oldLot.Notes = newLot.Notes; oldLot.PurchOrder = newLot.PurchaseOrderNumber; oldLot.ShipperNum = newLot.ShipperNumber; if (string.IsNullOrWhiteSpace(oldLot.Company_IA) || newLot.Vendor != null) { oldLot.Company_IA = newLot.Vendor == null ? null : newLot.Vendor.Name; } LotSyncHelper.SetLotAttributes(oldLot, newLot.Attributes.ToList()); LotSyncHelper.SetTestData(oldLot, newLot); LotSyncHelper.SetLotStat(oldLot, newLot, completedOverride, newLot.ChileLot == null ? null : newLot.ChileLot.ChileProduct.ProductAttributeRanges.ToList()); } oldLot.Serialized = SerializableLot.Serialize(newLot); }
public void Clears_missing_attribute_values() { //Arrange var lot = new tblLot { Ash = 11, AToxin = 22, Gluten = 33 }; var asta = BuildLotAttribute(StaticAttributeNames.Asta, 1.0); var scoville = BuildLotAttribute(StaticAttributeNames.Scoville, 2.0f); var scan = BuildLotAttribute(StaticAttributeNames.Scan, 3.0); //Act LotSyncHelper.SetLotAttributes(lot, new List <LotAttribute> { asta, scoville, scan }); //Assert Assert.IsNotNull(lot.AvgAsta); Assert.IsNotNull(lot.AvgScov); Assert.IsNotNull(lot.Scan); Assert.IsNull(lot.Ash); Assert.IsNull(lot.AToxin); Assert.IsNull(lot.Gluten); }
public void UpdateOldLotAttributes(ILotKey lotKey, List <LotAttribute> newLotAttributes) { var lotNumber = LotNumberBuilder.BuildLotNumber(lotKey); var oldLot = _oldContext.tblLots .Include(l => l.tblLotAttributeHistory) .FirstOrDefault(l => l.Lot == lotNumber); if (oldLot == null) { throw new Exception(string.Format("Could not find tblLot[{0}]", lotNumber)); } SyncProductionBatchPickedInventoryHelper.SetLotBatchAttributes(oldLot, newLotAttributes); LotSyncHelper.SetLotAttributes(oldLot, newLotAttributes); }
public void Sets_lot_attribute_values_as_expected() { //Arrange var lot = new tblLot(); var asta = BuildLotAttribute(StaticAttributeNames.Asta, 1.0); var scoville = BuildLotAttribute(StaticAttributeNames.Scoville, 2.0f); var scan = BuildLotAttribute(StaticAttributeNames.Scan, 3.0); //Act LotSyncHelper.SetLotAttributes(lot, new List <LotAttribute> { asta, scoville, scan }); //Assert Assert.AreEqual(asta.AttributeValue, lot.AvgAsta); Assert.AreEqual(scoville.AttributeValue, lot.AvgScov); Assert.AreEqual(scan.AttributeValue, lot.Scan); }
public void Does_not_override_lot_attributes_with_computed_values() { //Arrange var lot = new tblLot { AvgAsta = 10 }; var asta = BuildLotAttribute(StaticAttributeNames.Asta, 1.0, null, true); var scoville = BuildLotAttribute(StaticAttributeNames.Scoville, 2.0f); var scan = BuildLotAttribute(StaticAttributeNames.Scan, 3.0); //Act LotSyncHelper.SetLotAttributes(lot, new List <LotAttribute> { asta, scoville, scan }); //Assert Assert.AreEqual(scoville.AttributeValue, lot.AvgScov); Assert.AreEqual(scan.AttributeValue, lot.Scan); Assert.AreEqual(10, lot.AvgAsta); }
private static void SetLotAttributes(ProductionBatch productionBatch, tblLot lot) { var lotAttributes = productionBatch.Production.ResultingChileLot.Lot.Attributes.ToList(); LotSyncHelper.SetLotAttributes(lot, lotAttributes); SetLotBatchAttributes(lot, lotAttributes); }