add example that doesnt use BaseHelper
This commit is contained in:
@ -1,18 +1,45 @@
|
||||
using COA.EnterpriseServices.DataAccess.Entities;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace COA.EnterpriseServices.DataAccess.Helpers
|
||||
{
|
||||
public class CreditorHelper : BaseHelper<Creditor>
|
||||
// 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 DataAccessManager<Creditor> creditorDataAccess;
|
||||
private static DataAccessManager<SettlementAttempt> settlementAttemptDataAccess;
|
||||
|
||||
public CreditorHelper()
|
||||
{
|
||||
creditorDataAccess = new DataAccessManager<Creditor>();
|
||||
settlementAttemptDataAccess = new DataAccessManager<SettlementAttempt>();
|
||||
}
|
||||
|
||||
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<Creditor> FindByName(string name)
|
||||
{
|
||||
return DataAccessManager.Invoke(d => d.Get(c => c.ClientFirstName.Contains(name) || c.ClientLastName.Contains(name)));
|
||||
return creditorDataAccess.Invoke(d => d.Get(c => c.ClientFirstName.Contains(name) || c.ClientLastName.Contains(name)));
|
||||
}
|
||||
|
||||
public ICollection<Creditor> FindByStatus(string status)
|
||||
{
|
||||
return DataAccessManager.Invoke(d => d.Get(c => c.Status == status));
|
||||
return creditorDataAccess.Invoke(d => d.Get(c => c.Status == status));
|
||||
}
|
||||
|
||||
public bool AddCreditor(Creditor creditor)
|
||||
{
|
||||
return creditorDataAccess.Invoke(d => d.Add(creditor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user