/// <summary> /// Attempts to get a batch from the underlying repository and throws a <see cref="MaterialBatchNotFoundException"/> if no matching batch could be found. /// </summary> /// <param name="id">ID of the material batch to get.</param> /// <exception cref="MaterialBatchNotFoundException">Thrown if no matching batch could be found.</exception> /// <returns>Returns the batch, if found.</returns> private MaterialBatch GetBatchOrThrowNotFoundException(Guid id) { MaterialBatch batch = MaterialBatchRepository.GetMaterialBatch(id); // Check for batch existence if (batch == null) { throw new MaterialBatchNotFoundException(id); } return(batch); }