/// <summary> /// Retrieves all related material data from a transaction. /// </summary> /// <typeparam name="Guid">ID of the transaction to use as a starting point.</typeparam> /// <returns>Returns a trace result on success.</returns> /// <exception cref="Exceptions.TransactionNotFoundException" /> /// <exception cref="Exceptions.MaterialBatchNotFoundException" /> /// <exception cref="Exceptions.MaterialNotFoundException" /> public TraceResult Trace(Guid transactionId) { // Get checkout transaction Transaction checkOutTransaction = TransactionLogService.GetTransaction(transactionId); // Get checkin transaction Transaction checkInTransaction = TransactionLogService.GetTransactionLog(checkOutTransaction.MaterialBatchId).Last(); // Get batch MaterialBatch batch = InventoryService.GetMaterialBatch(checkOutTransaction.MaterialBatchId); // Get and replace material data in extra step, since the InventoryService currently doesn't return custom material prop values Material material = MaterialsService.GetMaterial(batch.Material.Id); batch.Material = material; // Get temperature extrema Extrema temperature = EnvironmentService.GetExtrema(batch.StorageLocation.StorageSiteId, EnvironmentalFactor.Temperature, checkInTransaction.Timestamp, checkOutTransaction.Timestamp); // Get humidity extrema Extrema humidity = EnvironmentService.GetExtrema(batch.StorageLocation.StorageSiteId, EnvironmentalFactor.Humidity, checkInTransaction.Timestamp, checkOutTransaction.Timestamp); // Return trace result object return(new TraceResult() { Batch = batch, CheckInTransaction = checkInTransaction, CheckOutTransaction = checkOutTransaction, Temperature = temperature, Humidity = humidity }); }