add example that doesnt use BaseHelper
This commit is contained in:
parent
97622a576c
commit
9dca60bec7
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ namespace COA.EnterpriseServices.Sandbox
|
||||
var creditorHelper = new CreditorHelper();
|
||||
|
||||
// get single creditor
|
||||
var singleCreditor = creditorHelper.Get(1);
|
||||
var singleCreditor = creditorHelper.GetCreditor(1);
|
||||
|
||||
// search creditors
|
||||
var searchedCreditors = creditorHelper.FindByName("Guy");
|
||||
@ -31,7 +31,7 @@ namespace COA.EnterpriseServices.Sandbox
|
||||
Status = "Active"
|
||||
};
|
||||
|
||||
creditorHelper.Add(newCreditor);
|
||||
creditorHelper.AddCreditor(newCreditor);
|
||||
}
|
||||
|
||||
private static void ClientStuff()
|
||||
|
Loading…
Reference in New Issue
Block a user