public IEnumerable <ProductionResultItemResult> CreateNewProductionResultItems(ILotKey lotKey, ProductionBatchEntityObjectMother.tblLotResultDTO outputLot) { var sequence = 1; var productionResults = outputLot.tblIncomings.Where(i => i.TTypeID == (int?)TransType.Production).ToList(); foreach (var item in productionResults) { var result = CreateNewProductionResultItemResult.Success; LotProductionResultItem resultItem = null; var packagingProduct = _newContextHelper.GetPackagingProduct(item.PkgID); if (packagingProduct == null) { result = CreateNewProductionResultItemResult.PackagingProductNotFound; goto result; } var warehouseLocation = _newContextHelper.GetLocation(item.LocID); if (warehouseLocation == null) { result = CreateNewProductionResultItemResult.WarehouseLocationNotFound; goto result; } var treatment = _newContextHelper.GetInventoryTreatment(item.TrtmtID); if (treatment == null) { result = CreateNewProductionResultItemResult.InventoryTreatmentNotFound; goto result; } resultItem = new LotProductionResultItem { LotDateCreated = lotKey.LotKey_DateCreated, LotDateSequence = lotKey.LotKey_DateSequence, LotTypeId = lotKey.LotKey_LotTypeId, ResultItemSequence = sequence++, PackagingProductId = packagingProduct.Id, LocationId = warehouseLocation.Id, TreatmentId = treatment.Id, Quantity = (int)(item.Quantity ?? 0) }; result: yield return(new ProductionResultItemResult { Result = result, Source = item, ResultItem = resultItem }); } }
public Result DeterminePickedFromLocation(ProductionBatchEntityObjectMother.tblBatchItemDTO batchItem, out int?warehouseLocationId) { warehouseLocationId = null; var outgoing = batchItem.tblLot.tblOutgoings.Where(o => o.BatchLot == batchItem.NewLot).OrderByDescending(o => o.EntryDate).ToList(); Location facilityLocation = null; if (outgoing.Any(o => (facilityLocation = _newContextHelper.GetLocation(o.LocID)) != null)) { warehouseLocationId = facilityLocation.Id; return(Result.DeterminedFromOutgoingRecords); } if ((facilityLocation = _newContextHelper.GetLocation(batchItem.LocID)) != null) { warehouseLocationId = facilityLocation.Id; return(Result.DeterminedFromBatchItemLocation); } return(Result.UnableToDetermine); }