add Raw to DAM. add initial support for uspCreditorPortal_SettlementAttemptGet
This commit is contained in:
parent
7ad01a2586
commit
79b3b5be1d
@ -35,6 +35,18 @@ namespace COA.EnterpriseServices.DataAccess
|
||||
return Invoke<T, ICollection<T>>(d => d.Get(query));
|
||||
}
|
||||
|
||||
public T Get<T>(int id) where T : class, IRecord
|
||||
{
|
||||
var item = Get<T>(i => i.Id == id);
|
||||
|
||||
if (item != null && item.Any())
|
||||
{
|
||||
return item.FirstOrDefault();
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
public bool Add<T>(T item) where T : class, IRecord
|
||||
{
|
||||
return Invoke<T, bool>(d => d.Add(item));
|
||||
@ -56,16 +68,9 @@ namespace COA.EnterpriseServices.DataAccess
|
||||
return Update(item);
|
||||
}
|
||||
|
||||
public T Get<T>(int id) where T : class, IRecord
|
||||
public ICollection<T> Raw<T>(string command, params object[] parameters) where T : class, IRecord
|
||||
{
|
||||
var item = Get<T>(i => i.Id == id);
|
||||
|
||||
if (item != null && item.Any())
|
||||
{
|
||||
return item.FirstOrDefault();
|
||||
}
|
||||
|
||||
return default;
|
||||
return Invoke<T, ICollection<T>>(d => d.Raw(command, parameters));
|
||||
}
|
||||
|
||||
private TResult Invoke<T, TResult>(Func<IDataAccess<T>, TResult> func) where T : class, IRecord
|
||||
|
@ -2,6 +2,7 @@
|
||||
using COA.EnterpriseServices.Creditors;
|
||||
using COA.EnterpriseServices.DataAccess.Entities;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace COA.EnterpriseServices.DataAccess.Helpers
|
||||
{
|
||||
@ -35,51 +36,58 @@ namespace COA.EnterpriseServices.DataAccess.Helpers
|
||||
|
||||
public ICollection<Creditors.SettlementAttempt> GetSettlements(SettlementAttemptFilter filter)
|
||||
{
|
||||
var dal2 = new DataAccessManager2();
|
||||
// we may use this non-generic throughout instead
|
||||
var dataAccess = new DataAccessManager2();
|
||||
|
||||
dal2.Get<Entities.Creditor>(c => c.ClientLastName == "Peters");
|
||||
// More info on "FromSqlRaw" => https://docs.microsoft.com/en-us/ef/core/querying/raw-sql
|
||||
var attempts = dataAccess.Raw<Entities.SettlementAttempt>("uspCreditorPortal_SettlementAttemptGet @SettlementAttemptID = {0}, @CreditorProfileID = {1}", filter.SettlementAttemptId, filter.CreditorProfileId);
|
||||
|
||||
return DBWrapper.ExecuteProcedure(QuickbaseConnectionString, "uspCreditorPortal_SettlementAttemptGet", cmd =>
|
||||
{
|
||||
if (filter != null)
|
||||
{
|
||||
cmd.CommandTimeout = 0;
|
||||
// TODO: write extension to map list of T to destination type
|
||||
return attempts
|
||||
.Select(a => mapper.Map<Creditors.SettlementAttempt>(a))
|
||||
.ToList();
|
||||
|
||||
cmd.Parameters.AddWithValue("@SettlementAttemptID", filter.SettlementAttemptId);
|
||||
cmd.Parameters.AddWithValue("@CreditorProfileID", filter.CreditorProfileId);
|
||||
cmd.Parameters.AddWithValue("@CreditorID", filter.CreditorId);
|
||||
cmd.Parameters.AddWithValue("@CreditorContactID", filter.CreditorContactId);
|
||||
cmd.Parameters.AddWithValue("@FirstPaymentDateStart", filter.FirstPaymentDateStart);
|
||||
cmd.Parameters.AddWithValue("@FirstPaymentDateEnd", filter.FirstPaymentDateEnd);
|
||||
cmd.Parameters.AddWithValue("@ResponseDateStart", filter.ResponseDateStart);
|
||||
cmd.Parameters.AddWithValue("@ResponseDateEnd", filter.ResponseDateEnd);
|
||||
cmd.Parameters.AddWithValue("@PortalSubmissionDateStart", filter.PortalSubmissionDateStart);
|
||||
cmd.Parameters.AddWithValue("@PortalSubmissionDateEnd", filter.PortalSubmissionDateEnd);
|
||||
//return DBWrapper.ExecuteProcedure(QuickbaseConnectionString, "uspCreditorPortal_SettlementAttemptGet", cmd =>
|
||||
//{
|
||||
// if (filter != null)
|
||||
// {
|
||||
// cmd.CommandTimeout = 0;
|
||||
|
||||
if (filter.SettlementAttemptIds.AnyAndNotNull())
|
||||
{
|
||||
cmd.Parameters.Add("@SettlementAttemptIDs", SqlDbType.Structured).Value = CreateIdsTable(filter.SettlementAttemptIds);
|
||||
}
|
||||
else if (filter.CreditorIds.AnyAndNotNull())
|
||||
{
|
||||
cmd.Parameters.Add("@CreditorIDs", SqlDbType.Structured).Value = CreateIdsTable(filter.CreditorIds);
|
||||
}
|
||||
}
|
||||
// cmd.Parameters.AddWithValue("@SettlementAttemptID", filter.SettlementAttemptId);
|
||||
// cmd.Parameters.AddWithValue("@CreditorProfileID", filter.CreditorProfileId);
|
||||
// cmd.Parameters.AddWithValue("@CreditorID", filter.CreditorId);
|
||||
// cmd.Parameters.AddWithValue("@CreditorContactID", filter.CreditorContactId);
|
||||
// cmd.Parameters.AddWithValue("@FirstPaymentDateStart", filter.FirstPaymentDateStart);
|
||||
// cmd.Parameters.AddWithValue("@FirstPaymentDateEnd", filter.FirstPaymentDateEnd);
|
||||
// cmd.Parameters.AddWithValue("@ResponseDateStart", filter.ResponseDateStart);
|
||||
// cmd.Parameters.AddWithValue("@ResponseDateEnd", filter.ResponseDateEnd);
|
||||
// cmd.Parameters.AddWithValue("@PortalSubmissionDateStart", filter.PortalSubmissionDateStart);
|
||||
// cmd.Parameters.AddWithValue("@PortalSubmissionDateEnd", filter.PortalSubmissionDateEnd);
|
||||
|
||||
return cmd.ToList<SettlementAttempt>();
|
||||
});
|
||||
// if (filter.SettlementAttemptIds.AnyAndNotNull())
|
||||
// {
|
||||
// cmd.Parameters.Add("@SettlementAttemptIDs", SqlDbType.Structured).Value = CreateIdsTable(filter.SettlementAttemptIds);
|
||||
// }
|
||||
// else if (filter.CreditorIds.AnyAndNotNull())
|
||||
// {
|
||||
// cmd.Parameters.Add("@CreditorIDs", SqlDbType.Structured).Value = CreateIdsTable(filter.CreditorIds);
|
||||
// }
|
||||
// }
|
||||
|
||||
// return cmd.ToList<SettlementAttempt>();
|
||||
//});
|
||||
}
|
||||
|
||||
public bool AddCreditor(Creditors.Creditor creditor)
|
||||
{
|
||||
var creditorEntity = mapper.Map<Creditor>(creditor);
|
||||
var creditorEntity = mapper.Map<Entities.Creditor>(creditor);
|
||||
|
||||
return creditorDataAccess.Add(creditorEntity);
|
||||
}
|
||||
|
||||
public bool UpdateCreditor(Creditors.Creditor creditor)
|
||||
{
|
||||
var creditorEntity = mapper.Map<Creditor>(creditor);
|
||||
var creditorEntity = mapper.Map<Entities.Creditor>(creditor);
|
||||
|
||||
return creditorDataAccess.Update(creditorEntity);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user