using COA.EnterpriseServices.DataAccess.Entities; using System.Collections.Generic; using System.Linq; namespace COA.EnterpriseServices.DataAccess.Helpers { // NOTE: This example does NOT use BaseHelper<> if you wish to manage it yourself // It allows for multiple DataAccessManagers to be used however needed by the helper public class CreditorHelper { private static readonly DataAccessManager creditorDataAccess; private static readonly DataAccessManager settlementAttemptDataAccess; static CreditorHelper() { creditorDataAccess = Dependencies.Container.GetInstance>(); settlementAttemptDataAccess = Dependencies.Container.GetInstance>(); } public Creditor GetCreditor(int id) { return creditorDataAccess.Invoke(d => d.Get(d => d.Id == id)?.FirstOrDefault()); } public SettlementAttempt GetSettlementAttempt(int id) { return settlementAttemptDataAccess.Invoke(d => d.Get(d => d.Id == id)?.FirstOrDefault()); } public ICollection FindByName(string name) { return creditorDataAccess.Invoke(d => d.Get(c => c.ClientFirstName.Contains(name) || c.ClientLastName.Contains(name))); } public ICollection FindByStatus(string status) { return creditorDataAccess.Invoke(d => d.Get(c => c.Status == status)); } public bool AddCreditor(Creditor creditor) { return creditorDataAccess.Invoke(d => d.Add(creditor)); } } }