public bool Match(IMaterialBatch batch, IBatchKeyResolver repo) { EnsureLoaded(repo); return(batch.MaterialId == m_materialId && batch.BatchNumber.Equals(m_batchNumber, StringComparison.InvariantCultureIgnoreCase)); }
private void EnsureLoaded(IBatchKeyResolver resolver) { if (m_materialId == null || string.IsNullOrWhiteSpace(m_batchNumber)) { if (resolver == null) { throw new InvalidOperationException("No resolver"); } var key = resolver.GetBatchNumberAndMaterialIdByBatchId(m_batchId ?? -1).Ensure(); m_materialId = key.Item1; m_batchNumber = key.Item2; } }
public bool Match(BatchKey key, IBatchKeyResolver repo) { if (key == null) { return(false); } var keyBnr = key.GetBatchNumber(repo); var keyMat = key.GetMaterialId(repo); var thiBnr = GetBatchNumber(repo); var thiMat = GetMaterialId(repo); return(keyBnr.Equals(thiBnr, StringComparison.InvariantCultureIgnoreCase) && keyMat == thiMat); }
public string ToString(IBatchKeyResolver repo) { EnsureLoaded(repo); return($"{m_batchNumber}:{m_materialId}"); }
public string GetBatchNumber(IBatchKeyResolver repo) { EnsureLoaded(repo); return(m_batchNumber); }
public int GetMaterialId(IBatchKeyResolver repo) { EnsureLoaded(repo); return(m_materialId ?? -1); }