This commit is contained in:
Zeeshaun
2026-04-20 14:47:24 -05:00
parent 89057eceea
commit 8b3ea92501
485 changed files with 71042 additions and 0 deletions
@@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Models.Results;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public class AuctionAssignmentNoteRepository : BaseRepository, IAuctionAssignmentNoteRepository
{
public AuctionAssignmentNoteRepository(AppDbContext context) : base(context) { }
public async Task<PagedResult<AuctionAssignmentNote>> ListAllAsync(int filterPage, int filterLimit)
{
var results = new PagedResult<AuctionAssignmentNote>();
var skip = (filterPage - 1) * filterLimit;
var temp = Queryable.OrderByDescending(from x in _context.AuctionAssignmentNotes
select x, x => x.Id);
results.Total = temp.Count();
results.Items = await temp.Skip(skip).Take(filterLimit).ToListAsync();
return results;
}
public async Task<AuctionAssignmentNote> FindByIdAsync(int id)
{
return await Queryable.Where(_context.AuctionAssignmentNotes, c => c.Id == id).FirstOrDefaultAsync();
}
public async Task<IEnumerable<AuctionAssignmentNote>> FindConflictingNotes(DateTime written, string text, string writer)
{
return await Queryable.Where(_context.AuctionAssignmentNotes, c => c.DateWritten == written && c.Text == text && c.Writer == writer).ToListAsync();
}
public async Task<AuctionAssignmentNote> AddAsync(AuctionAssignmentNote auctionAssignmentNote)
{
var result = await _context.AuctionAssignmentNotes.AddAsync(auctionAssignmentNote);
return result.Entity;
}
public void Update(AuctionAssignmentNote auctionAssignmentNote)
{
_context.AuctionAssignmentNotes.Update(auctionAssignmentNote);
}
public void Remove(AuctionAssignmentNote auctionAssignmentNote)
{
_context.AuctionAssignmentNotes.Remove(auctionAssignmentNote);
}
}
}
@@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Extensions;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Models.Results;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.Internal;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public class AuctionAssignmentRepository : BaseRepository, IAuctionAssignmentRepository
{
public AuctionAssignmentRepository(AppDbContext context) : base(context)
{
}
public async Task<PagedResult<AuctionAssignment>> ListAllAsync(int filterPage, int filterLimit)
{
var results = new PagedResult<AuctionAssignment>();
var skip = (filterPage - 1) * filterLimit;
var temp = (from x in _context.AuctionAssignments
select x).OrderByDescending(x => x.ID);
results.Total = temp.Count();
results.Items = await temp.Skip(skip).Take(filterLimit).IncludeAll().ToListAsync();
return results;
}
public async Task<PagedResult<AuctionAssignment>> ListReadyForFloorPriceAsync()
{
var results = new PagedResult<AuctionAssignment>();
var temp = (from x in _context.AuctionAssignments
where (x.FloorPrice ?? 0) == 0 && x.AutoIMS != null && x.AutoIMS.SoldDate == null &&
(x.AutoIMS.StatedMileage ?? -1) > 1 && x.AutoIMS.ScheduledSaleDate != null &&
x.AutoIMS.ScheduledSaleDate > DateTime.Now.Date &&
x.RedeemedDate == null &&
( (x.AutoIMS.ApprovedVehicleGrade ?? 0) > 0 || (x.AutoIMS.VehicleGrade ?? 0) > 0)
select x).OrderByDescending(x => x.ID);
results.Items = await temp.IncludeAll().ToListAsync();
results.Total = temp.Count();
return results;
}
public async Task<AuctionAssignment> FindByIdAsync(int id)
{
return await Queryable.Where(_context.AuctionAssignments, c => c.ID == id).IncludeAll().FirstOrDefaultAsync();
}
public async Task<IReadOnlyCollection<AuctionAssignment>> FindListByIdsAsync(IReadOnlyCollection<int> idSet)
{
return await Queryable.Where(_context.AuctionAssignments, c => idSet.Contains(c.ID)).ToListAsync();
}
public async Task<IReadOnlyCollection<AuctionAssignment>> FindByRepoIdAsync(int repoId)
{
return await _context.AuctionAssignments.Where(auctionAssignment => auctionAssignment.RepoId == repoId).IncludeAll().ToListAsync();
}
public async Task<AuctionAssignment> FindByByAuctionCustomerNoAndVin(string auctionCustomerNo, string vin)
{
return await Queryable
.Where(_context.AuctionAssignments, auctionAssignment =>
auctionAssignment.AuctionCustomerNo == auctionCustomerNo &&
auctionAssignment.CollateralVIN == vin &&
auctionAssignment.IsActive == true).IncludeAll().FirstOrDefaultAsync();
}
public async Task<AuctionAssignment> AddAsync(AuctionAssignment auctionAssignment)
{
var result = await _context.AuctionAssignments.AddAsync(auctionAssignment);
result.Entity.Auction = Queryable.Where(_context.Auctions, a => a.AuctionID == result.Entity.AuctionId)
.FirstOrDefault();
return result.Entity;
}
public void Update(AuctionAssignment auctionAssignment)
{
_context.AuctionAssignments.Update(auctionAssignment);
}
public void Remove(AuctionAssignment auctionAssignment)
{
_context.AuctionAssignments.Remove(auctionAssignment);
}
}
}
@@ -0,0 +1,43 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Models.Results;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public class AuctionHouseRepository : BaseRepository, IAuctionHouseRepository
{
public AuctionHouseRepository(AppDbContext context) : base(context)
{
}
public async Task<IEnumerable<AuctionHouse>> ListAllAsync()
{
return await _context.Auctions.ToListAsync();
}
public async Task AddAsync(AuctionHouse auction)
{
await _context.Auctions.AddAsync(auction);
}
public async Task<AuctionHouse> FindByIdAsync(string id)
{
return await Queryable.Where<AuctionHouse>(_context.Auctions, c => c.AuctionID == id).FirstOrDefaultAsync();
}
public void Update(AuctionHouse auction)
{
_context.Auctions.Update(auction);
}
public void Remove(AuctionHouse auction)
{
_context.Auctions.Remove(auction);
}
}
}
@@ -0,0 +1,51 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Models.Results;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public class AuditRecordRepository : BaseRepository, IAuditRecordRepository
{
public AuditRecordRepository(AppDbContext context) : base(context)
{
}
public async Task<PagedResult<AuditRecord>> ListAllAsync(int filterPage, int filterLimit)
{
var results = new PagedResult<AuditRecord>();
var skip = (filterPage - 1) * filterLimit;
var temp = Queryable.OrderByDescending<AuditRecord, int>((from x in _context.AuditRecords
where x.DatePerformed > DateTime.Today.AddDays(-120)
select x), x => x.ID);
results.Total = temp.Count();
results.Items = await temp.Skip(skip).Take(filterLimit).ToListAsync();
return results;
}
public async Task AddAsync(AuditRecord auditRecord)
{
await _context.AuditRecords.AddAsync(auditRecord);
}
public async Task<AuditRecord> FindByIdAsync(int id)
{
return await _context.AuditRecords.FindAsync(id);
}
public void Update(AuditRecord auditRecord)
{
_context.AuditRecords.Update(auditRecord);
}
public void Remove(AuditRecord auditRecord)
{
_context.AuditRecords.Remove(auditRecord);
}
}
}
@@ -0,0 +1,44 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using LCU.Shared.Collections.RepoApiLib.Extensions;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public class CollateralRepository : BaseRepository, ICollateralRepository
{
public CollateralRepository(AppDbContext context) : base(context)
{
}
public async Task<IEnumerable<Collateral>> ListAllAsync()
{
return await _context.Collaterals.IncludeAll().ToListAsync();
}
public async Task<Collateral> AddAsync(Collateral collateral)
{
var result = await _context.Collaterals.AddAsync(collateral);
return result.Entity;
}
public async Task<Collateral> FindByIdAsync(int id)
{
return await Queryable.Where<Collateral>(_context.Collaterals, c => c.CollateralId == id).IncludeAll().FirstOrDefaultAsync();
}
public void Update(Collateral collateral)
{
_context.Collaterals.Update(collateral);
}
public void Remove(Collateral collateral)
{
_context.Collaterals.Remove(collateral);
}
}
}
@@ -0,0 +1,266 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Exceptions;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
using Serilog;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public class EventAlertRepository : BaseRepository, IEventAlertRepository
{
private const string RepoStatus = "REPO";
private const string O4RStatus = "O4R";
private const int ClosedAccountCutoffDays = 90;
private static List<string> _nonRepeatingAlerts = new List<string>
{
"Credit Adjustment Received",
"Debit Adjustment Received",
"Notice of Plan to Sell Not Found",
"Notice of Repossession Not Found",
"RTC Letter Not Found"
};
public EventAlertRepository(AppDbContext context) : base(context)
{
}
public async Task<IEnumerable<EventAlert>> ListAllAsync()
{
return await _context.EventAlerts.ToListAsync();
}
public async Task<IEnumerable<EventAlert>> ListUnreadAsync()
{
var result = from alert in _context.EventAlerts
join repo in _context.RepoAccounts
on alert.AccountNo equals repo.AccountNo
join activeStatus in _context.RepoManualStatuses
on repo.Status equals activeStatus.Description
where activeStatus.WatchForStatusChanges && alert.DateMarkedRead == null
select alert;
return await result.Distinct().ToListAsync();
}
public async Task<IEnumerable<EventAlert>> ListWithinDateRangeAsync(DateTime start, DateTime end)
{
return await _context.EventAlerts.Where(e => e.DateAdded >= start && e.DateAdded <= end).ToListAsync();
}
public async Task<IEnumerable<EventAlert>> ListRepoNoAuctionAsync()
{
var closedDateCutoff = DateTime.Today.Subtract(TimeSpan.FromDays(ClosedAccountCutoffDays));
var accountsInRepo = (
from repo in _context.RepoAccounts
where repo.Status.Equals(RepoStatus) && (repo.DateClosed == null || repo.DateClosed > closedDateCutoff)
select repo);
var accountsInRepoWithAuction = (
from repo in accountsInRepo
join auctionAssignment in _context.AuctionAssignments
on repo.RepoId equals auctionAssignment.RepoId
where auctionAssignment.IsActive == true
select repo);
var accountsNoAuction = await accountsInRepo.Except(accountsInRepoWithAuction).ToListAsync();
return accountsNoAuction.Select(repo => new EventAlert()
{
AccountNo = repo.AccountNo,
RepoId = repo.RepoId,
Message = "Repo No Auction"
}).Distinct();
}
public async Task<IEnumerable<EventAlert>> ListRepoNoCompanyAsync()
{
return await ListStatusNoCompanyAsync(RepoStatus);
}
public async Task<IEnumerable<EventAlert>> ListO4rNoCompanyAsync()
{
return await ListStatusNoCompanyAsync(O4RStatus);
}
public async Task<IEnumerable<EventAlert>> ListStatusNoCompanyAsync(string status)
{
var closedDateCutoff = DateTime.Today.Subtract(TimeSpan.FromDays(ClosedAccountCutoffDays));
var result = from repo in _context.RepoAccounts
from collateral in _context.Collaterals.Where(c => c.RepoId == repo.RepoId)
from repoCompanySelection in _context.RepoCompanySelections.Where(x => x.CollateralId == collateral.CollateralId).DefaultIfEmpty()
where (repoCompanySelection == null || repoCompanySelection.RepoCompanyId == null) && repo.Status.Equals(status) && (repo.DateClosed == null || repo.DateClosed > closedDateCutoff)
select new EventAlert
{
AccountNo = repo.AccountNo,
RepoId = repo.RepoId,
Message = status + " No Repo Company"
};
var temp = await result.Distinct().ToListAsync();
return temp;
}
public async Task<IEnumerable<EventAlert>> ListReadyForRetitleAsync()
{
var result = from collateral in _context.Collaterals
join repo in _context.RepoAccounts
on collateral.RepoId equals repo.RepoId
join auctionAssignmentToCollateral in _context.AuctionAssignmentToCollaterals
on collateral.CollateralId equals auctionAssignmentToCollateral.CollateralId
join auctionAssignment in _context.AuctionAssignments
on auctionAssignmentToCollateral.AuctionAssignmentId equals auctionAssignment.ID
from data in Queryable.Where<ImsAutoFileData>(_context.ImsAutoFileData, ims => auctionAssignment.ID == ims.AuctionAssignmentId ||
(repo.RepoId == ims.RepoId && auctionAssignment.CollateralVIN == ims.VIN))
where collateral.RetitledInLandmarkName == null && repo.Status.Equals(RepoStatus) && auctionAssignment.IsActive && repo.RedemptionExpiredDate < DateTime.Today
select new EventAlert
{
AccountNo = repo.AccountNo,
RepoId = repo.RepoId,
Message = "Ready For Retitle"
};
return await result.Distinct().ToListAsync();
}
public async Task<IEnumerable<EventAlert>> ListFloorUpdateFailedAsync()
{
var result = from autoFileData in _context.ImsAutoFileData
join repo in _context.RepoAccounts
on autoFileData.RepoId equals repo.RepoId
join collateral in _context.Collaterals
on repo.RepoId equals collateral.RepoId
join auctionAssignmentToCollateral in _context.AuctionAssignmentToCollaterals
on collateral.CollateralId equals auctionAssignmentToCollateral.CollateralId
join auctionAssignment in _context.AuctionAssignments
on auctionAssignmentToCollateral.AuctionAssignmentId equals auctionAssignment.ID
where ((auctionAssignment.HoldStatus ?? 0) == 0 || (auctionAssignment.HoldUntil ?? DateTime.Now) <= DateTime.Now) &&
auctionAssignment.RedeemedDate == null &&
autoFileData.SoldDate == null &&
(auctionAssignment.FloorPriceResponseCode != null && auctionAssignment.FloorPriceResponseCode != 1)
select new EventAlert
{
AccountNo = repo.AccountNo,
RepoId = repo.RepoId,
Message = "Floor Update Failed"
};
return await result.Distinct().ToListAsync();
}
public async Task<IEnumerable<EventAlert>> ListFloorNeedsSettingAsync()
{
var result = from data in _context.ImsAutoFileData
join repo in _context.RepoAccounts
on data.RepoId equals repo.RepoId
join collateral in _context.Collaterals
on repo.RepoId equals collateral.RepoId
join auctionAssignmentToCollateral in _context.AuctionAssignmentToCollaterals
on collateral.CollateralId equals auctionAssignmentToCollateral.CollateralId
join auctionAssignment in _context.AuctionAssignments
on auctionAssignmentToCollateral.AuctionAssignmentId equals auctionAssignment.ID
where (auctionAssignment.FloorPrice ?? 0) == 0 &&
((auctionAssignment.HoldStatus ?? 0) == 0 || (auctionAssignment.HoldUntil ?? DateTime.Now) <= DateTime.Now) &&
auctionAssignment.RedeemedDate == null &&
data.SoldDate == null &&
data.ScheduledSaleDate != null &&
data.ScheduledSaleDate < DateTime.Now.AddDays(3) &&
repo.DateClosed == null
select new EventAlert
{
AccountNo = repo.AccountNo,
RepoId = repo.RepoId,
Message = "Floor Set Required"
};
return await result.Distinct().ToListAsync();
}
public async Task AddAsync(EventAlert eventAlert)
{
if (eventAlert.SubMessage != null && eventAlert.SubMessage.Length > 499)
{
eventAlert.SubMessage = eventAlert.SubMessage.Substring(0, 499);
}
if (!IsDuplicateAlert(eventAlert))
{
await _context.EventAlerts.AddAsync(eventAlert);
}
else
{
throw new DuplicateResourceException("EventAlert");
}
}
public async Task<IEnumerable<EventAlert>> AddRangeAsync(IEnumerable<EventAlert> eventAlerts)
{
List<EventAlert> filteredEventAlerts = new List<EventAlert>();
foreach (EventAlert eventAlert in eventAlerts)
{
if (eventAlert.SubMessage != null && eventAlert.SubMessage.Length > 499)
{
eventAlert.SubMessage = eventAlert.SubMessage.Substring(0, 499);
}
if (!IsDuplicateAlert(eventAlert))
{
filteredEventAlerts.Add(eventAlert);
}
else
{
Log.Debug($"EventAlertRepository: Valid Alert Already Exists eventAlert: {@eventAlert}." +
$" Will Continue without adding this to Event Alerts Context.", eventAlerts, eventAlert
);
}
}
await _context.EventAlerts.AddRangeAsync(filteredEventAlerts);
return filteredEventAlerts;
}
public bool IsDuplicateAlert(EventAlert eventAlert)
{
var duplicateAlerts = (
from alert in _context.EventAlerts
where alert.AccountNo == eventAlert.AccountNo &&
alert.Message == eventAlert.Message &&
(
alert.DateMarkedRead == null ||
alert.DateMarkedRead > DateTime.Now.AddHours(-24) ||
_nonRepeatingAlerts.Contains(alert.Message)
)
select alert
).ToList();
return (duplicateAlerts.Any());
}
public async Task<EventAlert> FindByIdAsync(int id)
{
return await _context.EventAlerts.FindAsync(id);
}
public void Update(EventAlert category)
{
_context.EventAlerts.Update(category);
}
public void Remove(EventAlert category)
{
_context.EventAlerts.Remove(category);
}
public async Task<IEnumerable<EventAlert>> ListUnreadByAccountNoAsync(string accountNo)
{
var results = _context.EventAlerts.Where(x => x.AccountNo == accountNo && x.DateMarkedRead == null);
return await results.ToListAsync();
}
}
}
@@ -0,0 +1,43 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public class ExternalUserRepository : BaseRepository, IExternalUserRepository
{
public ExternalUserRepository(AppDbContext context) : base(context) { }
public async Task<IReadOnlyCollection<ExternalUser>> ListAsync()
{
return await _context.ExternalUsers.AsNoTracking().ToListAsync();
}
public async Task<ExternalUser> FindByReferenceIdAsync(int referenceId)
{
return await _context.ExternalUsers.AsNoTracking().Where(user => user.ReferenceId == referenceId).FirstOrDefaultAsync();
}
public async Task SynchronizeSet(IReadOnlyCollection<ExternalUser> externalUsers)
{
foreach (var user in externalUsers)
{
var existing = await FindByReferenceIdAsync(user.ReferenceId);
if ( existing != null)
{
user.Id = existing.Id;
_context.Entry(user).State = EntityState.Modified;
_context.ExternalUsers.Update(user);
}
else
{
await _context.ExternalUsers.AddAsync(user);
}
}
}
}
}
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Models.Results;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public interface IAuctionAssignmentNoteRepository
{
Task<PagedResult<AuctionAssignmentNote>> ListAllAsync(int filterPage, int filterLimit);
Task<AuctionAssignmentNote> FindByIdAsync(int id);
Task<IEnumerable<AuctionAssignmentNote>> FindConflictingNotes(DateTime written, string text, string writer);
Task<AuctionAssignmentNote> AddAsync(AuctionAssignmentNote auctionAssignmentNote);
void Update(AuctionAssignmentNote auctionAssignmentNote);
void Remove(AuctionAssignmentNote auctionAssignmentNote);
}
}
@@ -0,0 +1,20 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Models.Results;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public interface IAuctionAssignmentRepository
{
Task<PagedResult<AuctionAssignment>> ListAllAsync(int filterPage, int filterLimit);
Task<PagedResult<AuctionAssignment>> ListReadyForFloorPriceAsync();
Task<AuctionAssignment> FindByIdAsync(int id);
Task<IReadOnlyCollection<AuctionAssignment>> FindByRepoIdAsync(int repoId);
Task<AuctionAssignment> FindByByAuctionCustomerNoAndVin(string auctionCustomerNo, string vin);
Task<AuctionAssignment> AddAsync(AuctionAssignment auctionAssignment);
void Update(AuctionAssignment auctionAssignment);
void Remove(AuctionAssignment auctionAssignment);
Task<IReadOnlyCollection<AuctionAssignment>> FindListByIdsAsync(IReadOnlyCollection<int> idSet);
}
}
@@ -0,0 +1,15 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public interface IAuctionHouseRepository
{
Task<IEnumerable<AuctionHouse>> ListAllAsync();
Task AddAsync(AuctionHouse assignment);
Task<AuctionHouse> FindByIdAsync(string id);
void Update(AuctionHouse assignment);
void Remove(AuctionHouse assignment);
}
}
@@ -0,0 +1,15 @@
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Models.Results;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public interface IAuditRecordRepository
{
Task<PagedResult<AuditRecord>> ListAllAsync(int filterPage, int filterLimit);
Task AddAsync(AuditRecord auditRecord);
Task<AuditRecord> FindByIdAsync(int id);
void Update(AuditRecord auditRecord);
void Remove(AuditRecord auditRecord);
}
}
@@ -0,0 +1,15 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public interface ICollateralRepository
{
Task<IEnumerable<Collateral>> ListAllAsync();
Task<Collateral> AddAsync(Collateral collateral);
Task<Collateral> FindByIdAsync(int id);
void Update(Collateral collateral);
void Remove(Collateral collateral);
}
}
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public interface IEventAlertRepository
{
Task<IEnumerable<EventAlert>> ListAllAsync();
Task<IEnumerable<EventAlert>> ListUnreadAsync();
Task<IEnumerable<EventAlert>> ListWithinDateRangeAsync(DateTime start, DateTime end);
Task<IEnumerable<EventAlert>> ListRepoNoAuctionAsync();
Task<IEnumerable<EventAlert>> ListRepoNoCompanyAsync();
Task<IEnumerable<EventAlert>> ListO4rNoCompanyAsync();
Task<IEnumerable<EventAlert>> ListReadyForRetitleAsync();
Task<IEnumerable<EventAlert>> ListFloorUpdateFailedAsync();
Task<IEnumerable<EventAlert>> ListFloorNeedsSettingAsync();
Task<IEnumerable<EventAlert>> ListUnreadByAccountNoAsync(string accountNo);
Task AddAsync(EventAlert eventAlert);
Task<IEnumerable<EventAlert>> AddRangeAsync(IEnumerable<EventAlert> eventAlerts);
Task<EventAlert> FindByIdAsync(int id);
void Update(EventAlert eventAlert);
void Remove(EventAlert eventAlert);
}
}
@@ -0,0 +1,13 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public interface IExternalUserRepository
{
Task<IReadOnlyCollection<ExternalUser>> ListAsync();
Task<ExternalUser> FindByReferenceIdAsync(int referenceId);
Task SynchronizeSet(IReadOnlyCollection<ExternalUser> externalUsers);
}
}
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public interface IImsAutoFileDataRepository
{
Task<IEnumerable<ImsAutoFileData>> ListAllAsync();
Task AddAsync(ImsAutoFileData assignment);
Task<ImsAutoFileData> FindByIdAsync(string vin, int repoId);
Task<ImsAutoFileData> FindByAuctionAssignmentIdAsync(int auctionAssignmentId);
Task<ImsAutoFileData> GetNonConformingImsFileRecord(string vin, string auctionCustomerNo);
void Update(ImsAutoFileData autoImsAutoFileData);
void Remove(ImsAutoFileData autoImsAutoFileData);
Task<IReadOnlyCollection<ImsAutoFileData>> GetImsSoldRecordsForPeriod(DateTime lowDateTime, DateTime highDateTime);
}
}
@@ -0,0 +1,11 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public interface ILetterRepository
{
Task<IEnumerable<Letter>> ListAsync();
}
}
@@ -0,0 +1,17 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public interface IProcessingReceiptRepository
{
Task<IReadOnlyCollection<ProcessingReceipt>> FindReceiptsAsync(string accountNo,
string accountId = "", string caseId = "");
Task<IReadOnlyCollection<ProcessingReceipt>> GetReceiptsByAccountNoAsync(string accountNo);
Task<IReadOnlyCollection<ProcessingReceipt>> GetRetryListAsync();
Task AddOrUpdateAsync(ProcessingReceipt receipt);
Task SaveAllAsync(IReadOnlyCollection<ProcessingReceipt> receipts);
bool IsDuplicateReceipt(ProcessingReceipt newReceipt);
}
}
@@ -0,0 +1,14 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public interface IRefundStatusRepository
{
Task<IReadOnlyCollection<RefundStatus>> ListAsync();
Task<RefundStatus> FindByRepoIdAsync(int repoId);
Task<RefundStatus> AddAsync(RefundStatus refundStatus);
void Update(RefundStatus refundStatus);
}
}
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Models.Producer;
using LCU.Shared.Collections.RepoApiLib.Models.Results;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public interface IRepoAccountRepository
{
Task<PagedResult<RepoAccount>> ListAsync(List<int?> filterRepoIdList, int filterPage, int filterLimit, string status = null, string auctionHouseId = null, int? repoCompanyId = null, bool? onlyOpenAccounts = null);
Task<IReadOnlyCollection<RepoAccount>> ListByAuctionVinAsync(string unformattedVin);
Task<IReadOnlyCollection<RepoAccount>> FindByCurrentStatus(string currentStatus);
Task<IReadOnlyCollection<RepoAccount>> FindByStatusChangeInPeriod(string status, DateTime lowDateTime, DateTime highDateTime, string previousStatus = null);
Task<RepoAccount> AddAsync(RepoAccount repoAccount);
Task<RepoAccount> FindByIdAsync(int id);
Task<IReadOnlyCollection<RepoAccount>> FindByRepoIdAsync(List<string> filterRepoIdList);
Task<IReadOnlyCollection<RepoAccount>> SearchRepoAccounts(string searchPhrase, int maxLimit);
Task<IReadOnlyCollection<RepoAccount>> FindByAccountNoAsync(string accountNo);
Task<RepoAccount> FindByAuctionAssignmentIdAsync(int id);
Task<IReadOnlyCollection<RepoAccount>> GetCurrentAccountsOnHoldAtAuction();
void Update(RepoAccount eventAlert);
void Remove(RepoAccount eventAlert);
Task<IReadOnlyCollection<ProcessingItem>> GetItemsForProcessing(IReadOnlyCollection<string> watchStatusList);
}
}
@@ -0,0 +1,15 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public interface IRepoCompanyRepository
{
Task<IEnumerable<RepoCompany>> ListAsync();
Task<RepoCompany> AddAsync(RepoCompany repoCompany);
Task<RepoCompany> FindByIdAsync(int id);
void Update(RepoCompany repoCompany);
void Remove(RepoCompany repoCompany);
}
}
@@ -0,0 +1,18 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public interface IRepoCompanySelectionRepository
{
Task<IEnumerable<RepoCompanySelection>> ListAllAsync();
Task AddAsync(RepoCompanySelection repoCompanySelection);
Task<RepoCompanySelection> FindByIdAsync(int id);
Task<IEnumerable<RepoCompanySelection>> FindByCollateralIdAsync(int collateralId);
void Update(RepoCompanySelection repoCompanySelection);
void Remove(RepoCompanySelection repoCompanySelection);
void SaveRange(IList<RepoCompanySelection> repoCompanySelections);
}
}
@@ -0,0 +1,16 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public interface IRepoManualStatusRepository
{
Task<IReadOnlyCollection<RepoManualStatus>> ListAllAsync();
Task<IReadOnlyCollection<string>> ListWatchStatusesAsync();
Task AddAsync(RepoManualStatus repoManualStatus);
Task<RepoManualStatus> FindByIdAsync(int id);
void Update(RepoManualStatus repoManualStatus);
void Remove(RepoManualStatus repoManualStatus);
}
}
@@ -0,0 +1,14 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public interface IRepoStatusChangeRepository
{
Task<IEnumerable<RepoStatusChange>> ListAsync();
Task<IEnumerable<RepoStatusChange>> ListForAccountAsync(int repoAccountId);
Task<RepoStatusChange> AddAsync(RepoStatusChange statusChange);
Task<RepoStatusChange> FindByIdAsync(int id);
}
}
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Models.Reporting;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public interface IReportingRepository
{
Task<IReadOnlyCollection<RepoAccount>> GetAllAccountsInO4R();
Task<IReadOnlyCollection<LandmarkReportAccountEntry>> GetActiveAccounts();
Task<IReadOnlyCollection<LandmarkReportAccountEntry>> GetClosedAccounts(DateTime lowDateTime, DateTime highDateTime);
Task<IReadOnlyCollection<StdReportEntry>> GetAccountsByDateSoldInAutoIMS(DateTime lowDateTime, DateTime highDateTime);
Task<IReadOnlyCollection<StdReportEntry>> GetAccountsByDateRepoed(DateTime lowDateTime, DateTime highDateTime);
Task<IReadOnlyCollection<StdReportEntry>> GetAccountsByDateAssigned(DateTime lowDateTime, DateTime highDateTime);
Task<IReadOnlyCollection<StdReportEntry>> GetAccountsByO4RDate(DateTime lowDateTime, DateTime highDateTime);
Task<IReadOnlyCollection<StdReportEntry>> GetAccountsByStatusChangeInPeriod(string status, DateTime lowDateTime, DateTime highDateTime);
}
}
@@ -0,0 +1,15 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public interface ISavedLocationRepository
{
Task<IEnumerable<SavedLocation>> ListAsync();
Task<SavedLocation> AddAsync(SavedLocation savedLocation);
Task<SavedLocation> FindByIdAsync(int id);
void Update(SavedLocation savedLocation);
void Remove(SavedLocation savedLocation);
}
}
@@ -0,0 +1,9 @@
using System.Threading.Tasks;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public interface IUnitOfWork
{
Task CompleteAsync();
}
}
@@ -0,0 +1,15 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public interface IVehicleFloorPricingParametersRepository
{
Task<IEnumerable<VehicleFloorPricingParameters>> ListAllAsync();
Task AddAsync(VehicleFloorPricingParameters Collateral);
Task<VehicleFloorPricingParameters> FindByIdAsync(int id);
void Update(VehicleFloorPricingParameters Collateral);
void Remove(VehicleFloorPricingParameters Collateral);
}
}
@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public class ImsAutoFileDataRepository : BaseRepository, IImsAutoFileDataRepository
{
public ImsAutoFileDataRepository(AppDbContext context) : base(context)
{
}
public async Task<IEnumerable<ImsAutoFileData>> ListAllAsync()
{
return await _context.ImsAutoFileData.ToListAsync();
}
public async Task AddAsync(ImsAutoFileData assignment)
{
await _context.ImsAutoFileData.AddAsync(assignment);
}
public async Task<ImsAutoFileData> FindByIdAsync(string vin, int repoId)
{
return await _context.ImsAutoFileData.Where(x => x.VIN == vin && x.RepoId == repoId).FirstOrDefaultAsync();
}
public async Task<ImsAutoFileData> FindByAuctionAssignmentIdAsync(int auctionAssignmentId)
{
return await _context.ImsAutoFileData.Where(x => x.AuctionAssignmentId == auctionAssignmentId)
.FirstOrDefaultAsync();
}
public async Task<ImsAutoFileData> GetNonConformingImsFileRecord(string vin, string auctionCustomerNo)
{
ImsAutoFileData imsAutoFile = null;
// Allow for vehicle brought back to auction after sale. it happens!
DateTime withinThirtyDays = DateTime.Now.AddDays(-30);
imsAutoFile = await _context.ImsAutoFileData.Where(x =>
(x.VIN.Trim() == vin && x.AuctionCustomerNo == auctionCustomerNo
&& (x.SoldDate == null || x.SoldDate >= withinThirtyDays))).FirstOrDefaultAsync();
return imsAutoFile;
}
public void Update(ImsAutoFileData autoImsAutoFileData)
{
_context.ImsAutoFileData.Update(autoImsAutoFileData);
}
public void Remove(ImsAutoFileData autoImsAutoFileData)
{
_context.ImsAutoFileData.Remove(autoImsAutoFileData);
}
public async Task<IReadOnlyCollection<ImsAutoFileData>> GetImsSoldRecordsForPeriod(DateTime lowDateTime,
DateTime highDateTime)
{
return await _context.ImsAutoFileData
.Where(x => x.SoldDate != null && x.SoldDate >= lowDateTime && x.SoldDate <= highDateTime)
.ToListAsync();
}
}
}
@@ -0,0 +1,20 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public class LetterRepository : BaseRepository, ILetterRepository
{
public LetterRepository(AppDbContext context) : base(context)
{
}
public async Task<IEnumerable<Letter>> ListAsync()
{
return await _context.Letters.ToListAsync();
}
}
}
@@ -0,0 +1,84 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Models.Producer;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public class ProcessingReceiptRepository : BaseRepository, IProcessingReceiptRepository
{
private readonly IReadOnlyCollection<RepoProcessingResult> _retryOutcomes = new List<RepoProcessingResult>()
{
RepoProcessingResult.Error, RepoProcessingResult.MissingRequirement
};
public ProcessingReceiptRepository(AppDbContext context) : base(context)
{
}
public async Task<IReadOnlyCollection<ProcessingReceipt>> FindReceiptsAsync(string accountNo,
string accountId = "", string caseId = "")
{
return await _context.ProcessingReceipts.Where(receipt => receipt.AccountNo == accountNo
&& receipt.AccountId == accountId &&
receipt.CaseId == caseId).AsNoTracking().ToListAsync();
}
public async Task<IReadOnlyCollection<ProcessingReceipt>> GetReceiptsByAccountNoAsync(string accountNo)
{
return await _context.ProcessingReceipts.Where(receipt => receipt.AccountNo == accountNo).AsNoTracking().ToListAsync();
}
public async Task<IReadOnlyCollection<ProcessingReceipt>> GetRetryListAsync()
{
return await _context.ProcessingReceipts.Where(receipt => _retryOutcomes.Contains(receipt.Outcome))
.AsNoTracking().ToListAsync();
}
public async Task AddOrUpdateAsync(ProcessingReceipt receipt)
{
if (receipt.Message != null && receipt.Message.Length > 124)
{
receipt.Message = receipt.Message.Substring(0, 124);
}
if (receipt.QueuedBy != null && receipt.QueuedBy.Length > 39)
{
receipt.QueuedBy = receipt.QueuedBy.Substring(0, 39);
}
if (!IsDuplicateReceipt(receipt))
{
await _context.ProcessingReceipts.AddAsync(receipt);
}
else
{
_context.Entry(receipt).State = EntityState.Modified;
_context.ProcessingReceipts.Update(receipt);
}
}
public async Task SaveAllAsync(IReadOnlyCollection<ProcessingReceipt> receipts)
{
var saveAllReceipts = receipts.Select(AddOrUpdateAsync).ToList();
await Task.WhenAll(saveAllReceipts);
}
public bool IsDuplicateReceipt(ProcessingReceipt newReceipt)
{
var duplicateReceipts = (
from existingReceipt in _context.ProcessingReceipts
where existingReceipt.AccountNo == newReceipt.AccountNo
&& existingReceipt.AccountId == newReceipt.AccountId
&& existingReceipt.CaseId == newReceipt.CaseId
select existingReceipt
).AsNoTracking().ToList();
return (duplicateReceipts.Count() != 0);
}
}
}
@@ -0,0 +1,35 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public class RefundStatusRepository : BaseRepository, IRefundStatusRepository
{
public RefundStatusRepository(AppDbContext context) : base(context) {}
public async Task<IReadOnlyCollection<RefundStatus>> ListAsync()
{
return await _context.RefundStatuses.ToListAsync();
}
public async Task<RefundStatus> FindByRepoIdAsync(int repoId)
{
return await _context.RefundStatuses.Where(refundStatus => refundStatus.RepoId == repoId).FirstOrDefaultAsync();
}
public async Task<RefundStatus> AddAsync(RefundStatus refundStatus)
{
var result = await _context.RefundStatuses.AddAsync(refundStatus);
return result.Entity;
}
public void Update(RefundStatus refundStatus)
{
_context.RefundStatuses.Update(refundStatus);
}
}
}
@@ -0,0 +1,234 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Exceptions;
using LCU.Shared.Collections.RepoApiLib.Extensions;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Models.Producer;
using LCU.Shared.Collections.RepoApiLib.Models.Results;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public class RepoAccountRepository : BaseRepository, IRepoAccountRepository
{
public RepoAccountRepository(AppDbContext context) : base(context)
{
}
public async Task<PagedResult<RepoAccount>> ListAsync(
List<int?> filterAccountNoList,
int filterPage,
int filterLimit,
string status,
string auctionHouseId,
int? repoCompanyId,
bool? onlyOpenAccounts)
{
var results = new PagedResult<RepoAccount>();
var skip = (filterPage - 1) * filterLimit;
var accounts = _context.RepoAccounts.Select(account => account);
// Filter By Repo Ids?
if (filterAccountNoList != null && filterAccountNoList.Any())
{
accounts = accounts.Where(account => filterAccountNoList.Contains(account.RepoId));
}
// Filter By Status?
if (!string.IsNullOrEmpty(status))
{
accounts = accounts.Where(account => account.Status.ToLower() == status.ToLower());
}
// Filter By Auction House?
if (!string.IsNullOrEmpty(auctionHouseId))
{
accounts = accounts.Join(_context.AuctionAssignments.AsEnumerable(), account => account.RepoId, auction => auction.RepoId,
(account, auction) => new { AuctionAssignment = auction, RepoAccount = account })
.Where(joined => joined.AuctionAssignment.IsActive && joined.AuctionAssignment.AuctionId == auctionHouseId)
.Select(result => result.RepoAccount);
}
// Filter By Repo Company?
if (repoCompanyId != null)
{
accounts = accounts.Join(_context.Collaterals.AsEnumerable(), account => account.RepoId, collateral => collateral.RepoId,
(account, collateral) => new { RepoAccount = account, Collateral = collateral })
.Join(_context.RepoCompanySelections.AsEnumerable(), accountCollateral => accountCollateral.Collateral.CollateralId,
repocompany => repocompany.CollateralId,
(accountCollateral, repocompany) => new { accountCollateral.RepoAccount, accountCollateral.Collateral, RepoCompany = repocompany })
.Where(joined => joined.RepoCompany.RepoCompanyId == repoCompanyId)
.Select(result => result.RepoAccount);
}
// Filter Out Closed Accounts?
if (onlyOpenAccounts == true)
{
accounts = accounts.Where(account => !account.DateClosed.HasValue);
}
accounts = accounts.Distinct();
results.Total = accounts.Count();
results.Items = await accounts.Skip(skip).Take(filterLimit).IncludeAll().ToListAsync();
return results;
}
public async Task<IReadOnlyCollection<RepoAccount>> FindByRepoIdAsync(List<string> filterRepoIdList)
{
var accounts = await Queryable.OrderByDescending<RepoAccount, string>((from account in _context.RepoAccounts
where filterRepoIdList.Count == 0 || filterRepoIdList.Contains(account.RepoId.ToString())
select account), x => x.AccountNo).IncludeAll().ToListAsync();
return accounts;
}
public async Task<IReadOnlyCollection<RepoAccount>> ListByAuctionVinAsync(string unformattedVin)
{
string vin = unformattedVin.Trim().ToUpper();
List<RepoAccount> repos = await (from account in _context.RepoAccounts
join collateral in _context.Collaterals on account.RepoId equals collateral.RepoId
where GetFormattedVIN(collateral.Vin) == vin
select account).ToListAsync();
return repos;
}
public async Task<IReadOnlyCollection<RepoAccount>> FindByStatusChangeInPeriod(
string status,
DateTime lowDateTime,
DateTime highDateTime,
string previousStatus = null)
{
var repos = await (
from account in _context.RepoAccounts
join statusChange in _context.RepoStatusChanges on account.RepoId equals statusChange.RepoId
where
string.Equals(account.Status, status, StringComparison.CurrentCultureIgnoreCase) &&
(
previousStatus != null
? string.Equals(statusChange.StatusFrom, previousStatus, StringComparison.CurrentCultureIgnoreCase)
: true
) &&
string.Equals(statusChange.StatusTo, status, StringComparison.CurrentCultureIgnoreCase) &&
statusChange.ChangedDate >= lowDateTime && statusChange.ChangedDate <= highDateTime
select account)
.Distinct()
.IncludeAll()
.ToListAsync();
return repos;
}
public async Task<RepoAccount> AddAsync(RepoAccount repo)
{
var result = await _context.RepoAccounts.AddAsync(repo);
return result.Entity;
}
public async Task<RepoAccount> FindByIdAsync(int id)
{
return await Queryable.Where(_context.RepoAccounts, x => x.RepoId == id)
.IncludeAll()
.FirstOrDefaultAsync();
}
public async Task<IReadOnlyCollection<RepoAccount>> FindByAccountNoAsync(string accountNo)
{
return await Queryable.Where<RepoAccount>(_context.RepoAccounts, x => x.AccountNo == accountNo)
.IncludeAll().AsNoTracking().ToListAsync();
}
public async Task<RepoAccount> FindByAuctionAssignmentIdAsync(int id)
{
RepoAccount repo = await (
from account in _context.RepoAccounts
join collateral in _context.Collaterals on account.RepoId equals collateral.RepoId
join auctionAssignmentToCollateral in _context.AuctionAssignmentToCollaterals on collateral.CollateralId equals auctionAssignmentToCollateral
.CollateralId
where auctionAssignmentToCollateral.AuctionAssignmentId == id
select account).FirstOrDefaultAsync();
return repo;
}
public static string GetFormattedVIN(string vin)
{
return vin.Trim().PadLeft(17, '0').ToUpper();
}
public void Update(RepoAccount account)
{
_context.Entry(account).State = EntityState.Modified;
_context.RepoAccounts.Update(account);
}
public void Remove(RepoAccount account)
{
_context.RepoAccounts.Remove(account);
}
public async Task<IReadOnlyCollection<ProcessingItem>> GetItemsForProcessing(IReadOnlyCollection<string> watchStatusList)
{
var accountList = await _context.RepoAccounts.Where(account =>
account.DateClosed == null && watchStatusList.Contains(account.Status.ToUpper().Trim())).ToListAsync();
var list = accountList.Select(x => new ProcessingItem()
{
AccountId = x.ReferenceId.HasValue ? x.ReferenceId.ToString() : "",
CaseId = x.ReferenceCaseId.HasValue ? x.ReferenceCaseId.ToString() : "",
AccountNo = x.AccountNo
});
return list.ToList();
}
public async Task<IReadOnlyCollection<RepoAccount>> SearchRepoAccounts(string searchPhrase, int maxLimit)
{
var updatedSearchPhrase = searchPhrase.Trim().ToLower();
var entities = (
from account in _context.RepoAccounts
join collateral in _context.Collaterals on account.RepoId equals collateral.RepoId
join member in _context.Borrowers on account.RepoId equals member.RepoId
where
account.AccountNo.ToLower().Contains(updatedSearchPhrase) ||
collateral.Vin.ToLower().Contains(updatedSearchPhrase) ||
member.IndividualName.ToLower().Contains(updatedSearchPhrase)
select account
);
var itemsFound = entities.Count();
if (itemsFound > maxLimit)
{
throw new MaxItemException(itemsFound);
}
return await entities
.IncludeAll().Distinct() /* distinct because repo can have multiple collaterals, borrowers */
.ToListAsync();
}
public async Task<IReadOnlyCollection<RepoAccount>> FindByCurrentStatus(string currentStatus)
{
return await _context.RepoAccounts.Where(repoAccount =>
repoAccount.Status.ToLower() == currentStatus.ToLower()).IncludeAll().ToListAsync();
}
public async Task<IReadOnlyCollection<RepoAccount>> GetCurrentAccountsOnHoldAtAuction()
{
var noHoldStatus = 0;
return await (
from repo in _context.RepoAccounts
join auctionAssignment in _context.AuctionAssignments on repo.RepoId equals auctionAssignment.RepoId
where
auctionAssignment.HoldStatus != noHoldStatus &&
DateTime.Now < auctionAssignment.HoldUntil
select repo).Distinct().IncludeAll().ToListAsync();
}
}
}
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public class RepoCompanyRepository : BaseRepository, IRepoCompanyRepository
{
public RepoCompanyRepository(AppDbContext context) : base(context)
{
}
public async Task<IEnumerable<RepoCompany>> ListAsync()
{
return await _context.RepoCompanies.ToListAsync();
}
public async Task<RepoCompany> AddAsync(RepoCompany repoCompany)
{
var result = await _context.RepoCompanies.AddAsync(repoCompany);
return result.Entity;
}
public async Task<RepoCompany> FindByIdAsync(int id)
{
return await Queryable.Where<RepoCompany>(_context.RepoCompanies, x => x.ID == id).FirstOrDefaultAsync();
}
public void Update(RepoCompany repoCompany)
{
_context.RepoCompanies.Update(repoCompany);
}
public void Remove(RepoCompany repoCompany)
{
_context.RepoCompanies.Remove(repoCompany);
}
}
}
@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public class RepoCompanySelectionRepository : BaseRepository, IRepoCompanySelectionRepository
{
public RepoCompanySelectionRepository(AppDbContext context) : base(context) {}
public async Task AddAsync(RepoCompanySelection repoCompanySelection)
{
repoCompanySelection.Id = null;
repoCompanySelection.DateTimeCreated = DateTime.Now;
await _context.RepoCompanySelections.AddAsync(repoCompanySelection);
}
public async Task<RepoCompanySelection> FindByIdAsync(int id)
{
return await _context.RepoCompanySelections.Where(repoCompanySelection => repoCompanySelection.Id == id).FirstOrDefaultAsync();
}
public async Task<IEnumerable<RepoCompanySelection>> FindByCollateralIdAsync(int collateralId)
{
return await _context.RepoCompanySelections.Where(repoCompanySelection => repoCompanySelection.CollateralId == collateralId).ToListAsync();
}
public async Task<IEnumerable<RepoCompanySelection>> ListAllAsync()
{
return await _context.RepoCompanySelections.ToListAsync();
}
public void Remove(RepoCompanySelection repoCompanySelection)
{
_context.RepoCompanySelections.Remove(repoCompanySelection);
}
public void Update(RepoCompanySelection repoCompanySelection)
{
_context.RepoCompanySelections.Update(repoCompanySelection);
}
public void SaveRange(IList<RepoCompanySelection> repoCompanySelections)
{
_context.RepoCompanySelections.UpdateRange(repoCompanySelections);
}
}
}
@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Exceptions;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public class RepoManualStatusRepository : BaseRepository, IRepoManualStatusRepository
{
public RepoManualStatusRepository(AppDbContext context) : base(context)
{
}
public async Task<IReadOnlyCollection<RepoManualStatus>> ListAllAsync()
{
return await _context.RepoManualStatuses.ToListAsync();
}
public async Task<IReadOnlyCollection<string>> ListWatchStatusesAsync()
{
var statusSet = await (from status in _context.RepoManualStatuses
where status.WatchForStatusChanges == true
select status).ToListAsync();
return statusSet.Select(x => x.Description).ToList() as IReadOnlyCollection<string>;
}
public async Task AddAsync(RepoManualStatus repoManualStatus)
{
// Only Create the Alert if an identical one doesn't already exist
var duplicateStatus = (
from status in _context.RepoManualStatuses
where status.Description.ToUpper().Trim() == repoManualStatus.Description.ToUpper().Trim()
select status
);
if (!duplicateStatus.Any())
{
await _context.RepoManualStatuses.AddAsync(repoManualStatus);
}
else
{
throw new DuplicateResourceException("RepoManualStatus");
}
}
public async Task<RepoManualStatus> FindByIdAsync(int id)
{
return await _context.RepoManualStatuses.FindAsync(id);
}
public void Update(RepoManualStatus repoManualStatus)
{
_context.RepoManualStatuses.Update(repoManualStatus);
}
public void Remove(RepoManualStatus repoManualStatus)
{
_context.RepoManualStatuses.Remove(repoManualStatus);
}
}
}
@@ -0,0 +1,38 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public class RepoStatusChangeRepository : BaseRepository, IRepoStatusChangeRepository
{
public RepoStatusChangeRepository(AppDbContext context) : base(context)
{
}
public async Task<IEnumerable<RepoStatusChange>> ListAsync()
{
return await _context.RepoStatusChanges.ToListAsync();
}
public async Task<IEnumerable<RepoStatusChange>> ListForAccountAsync(int repoAccountId)
{
return await Queryable.Where<RepoStatusChange>(_context.RepoStatusChanges, p => p.RepoId == repoAccountId).ToListAsync();
}
public async Task<RepoStatusChange> AddAsync(RepoStatusChange statusChange)
{
var result = await _context.RepoStatusChanges.AddAsync(statusChange);
return result.Entity;
}
public async Task<RepoStatusChange> FindByIdAsync(int id)
{
return await _context.RepoStatusChanges.FindAsync(id);
}
}
}
@@ -0,0 +1,255 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Extensions;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Models.Reporting;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public class ReportingRepository : BaseRepository, IReportingRepository
{
public ReportingRepository(AppDbContext context) : base(context)
{
}
// Maybe return a condensed object specifically meant for the frontend?
public async Task<IReadOnlyCollection<RepoAccount>> GetAllAccountsInO4R()
{
return await _context.RepoAccounts.Where(repoAccount => repoAccount.Status == "O4R")
.IncludeAll()
.ToListAsync();
}
public async Task<IReadOnlyCollection<LandmarkReportAccountEntry>> GetActiveAccounts()
{
return await _context.ActiveAccountEntries.FromSql(
@"select repos.repoId as RepoId, repos.DaysDelinquent as DaysDelinquent, repos.LastPaymentDate as LastPaymentDate, repos.LstPmtAmt as LastPaymentAmount,
Repos.Balance as Balance, Repos.AccountTypeCode as AccountTypeCode, Repos.Bankruptcy as Bankruptcy, Repos.DateClosed as DateClosed,
Repos.DelinquentAmount as DelinquentAmount, Repos.Collector as Collector, Borrowers.IndividualName, repos.AccountNo as AccountNo,
Collaterals.Year as Year, Collaterals.Make as Make, Collaterals.Model as Model, RepoCompany.Name as RepoCompany,
RepoCompanySelections.DateRepoed as DateRepoed, RepoCompanySelections.RepoType,
RepoCompanySelections.RepoCompanyAssignmentDate as DateAssigned,
Repos.Status as Status, DATEDIFF(day, RepoStatusChanges.ChangedDate, CURRENT_TIMESTAMP) as DaysInStatus, IMSAutoFileData.SoldDate as SoldDate,
IMSAutoFileData.DateEnteredAutoIMS as DateEnteredAutoIMS, IMSAutoFileData.FloorPriceAccepted as FloorPrice, IMSAutoFileData.VehicleGrade as Grade,
IMSAutoFileData.ScheduledSaleDate as ScheduledSaleDate, IMSAutoFileData.TotalCharges as TotalCharges,
IMSAutoFileData.GrossPercentFloor as GrossPercentFloor, IMSAutoFileData.NetPercentFloor as NetPercentFloor,
IMSAutoFileData.SalePrice as GrossSalePrice,
Auctions.Name as AuctionHouse, AuctionAssignments.DateSubmitted as AuctionDate
From repos
left join RepoStatusChanges on RepoStatusChanges.RepoId = Repos.RepoId
and RepoStatusChanges.ChangedDate = (select max(ChangedDate) from RepoStatusChanges where RepoId = repos.RepoId)
join Borrowers on Borrowers.RepoId = Repos.RepoId and Borrowers.OwnershipType = 6
join Collaterals on Collaterals.RepoId = Repos.RepoId
join RepoCompanySelections on Collaterals.CollateralId = RepoCompanySelections.CollateralId and RepoCompanySelections.DateTimeCreated = (select max(DateTimeCreated) from RepoCompanySelections where CollateralId = Collaterals.CollateralId)
left join RepoCompany on RepoCompanySelections.RepoCompanyId = RepoCompany.ID
left join AuctionAssignmentsToCollaterals on Collaterals.CollateralId = AuctionAssignmentsToCollaterals.CollateralId
left join AuctionAssignments on AuctionAssignmentsToCollaterals.AuctionAssignmentId = AuctionAssignments.ID
left join IMSAutoFileData on Repos.RepoId = IMSAutoFileData.RepoId
left join Auctions on Auctions.AuctionID = AuctionAssignments.AuctionId
where repos.status != 'REDEEMED' and repos.dateclosed is null
order by DateAssigned desc;
").ToListAsync();
}
public async Task<IReadOnlyCollection<LandmarkReportAccountEntry>> GetClosedAccounts(DateTime lowDateTime, DateTime highDateTime)
{
var lowDate = new SqlParameter("lowDate", lowDateTime);
var highDate = new SqlParameter("highDate", highDateTime);
return await _context.ActiveAccountEntries.FromSql(
@"select repos.repoId as RepoId, repos.DaysDelinquent as DaysDelinquent, repos.LastPaymentDate as LastPaymentDate, repos.LstPmtAmt as LastPaymentAmount,
Repos.Balance as Balance, Repos.AccountTypeCode as AccountTypeCode, Repos.Bankruptcy as Bankruptcy, Repos.DateClosed as DateClosed,
Repos.DelinquentAmount as DelinquentAmount, Repos.Collector as Collector, Borrowers.IndividualName, repos.AccountNo as AccountNo,
Collaterals.Year as Year, Collaterals.Make as Make, Collaterals.Model as Model, RepoCompany.Name as RepoCompany,
RepoCompanySelections.DateRepoed as DateRepoed, RepoCompanySelections.RepoType,
RepoCompanySelections.RepoCompanyAssignmentDate as DateAssigned,
Repos.Status as Status, DATEDIFF(day, RepoStatusChanges.ChangedDate, CURRENT_TIMESTAMP) as DaysInStatus, IMSAutoFileData.SoldDate as SoldDate,
IMSAutoFileData.DateEnteredAutoIMS as DateEnteredAutoIMS, IMSAutoFileData.FloorPriceAccepted as FloorPrice, IMSAutoFileData.VehicleGrade as Grade,
IMSAutoFileData.ScheduledSaleDate as ScheduledSaleDate, IMSAutoFileData.TotalCharges as TotalCharges,
IMSAutoFileData.GrossPercentFloor as GrossPercentFloor, IMSAutoFileData.NetPercentFloor as NetPercentFloor,
IMSAutoFileData.SalePrice as GrossSalePrice,
Auctions.Name as AuctionHouse, AuctionAssignments.DateSubmitted as AuctionDate
From repos
left join RepoStatusChanges on RepoStatusChanges.RepoId = Repos.RepoId
and RepoStatusChanges.ChangedDate = (select max(ChangedDate) from RepoStatusChanges where RepoId = repos.RepoId)
join Borrowers on Borrowers.RepoId = Repos.RepoId and Borrowers.OwnershipType = 6
join Collaterals on Collaterals.RepoId = Repos.RepoId
join RepoCompanySelections on Collaterals.CollateralId = RepoCompanySelections.CollateralId and RepoCompanySelections.DateTimeCreated = (select max(DateTimeCreated) from RepoCompanySelections where CollateralId = Collaterals.CollateralId)
left join RepoCompany on RepoCompanySelections.RepoCompanyId = RepoCompany.ID
left join AuctionAssignmentsToCollaterals on Collaterals.CollateralId = AuctionAssignmentsToCollaterals.CollateralId
left join AuctionAssignments on AuctionAssignmentsToCollaterals.AuctionAssignmentId = AuctionAssignments.ID
left join IMSAutoFileData on Repos.RepoId = IMSAutoFileData.RepoId
left join Auctions on Auctions.AuctionID = AuctionAssignments.AuctionId
where repos.status in ('PSKP', 'REDEEMED') or (repos.DateClosed is not null and repos.DateClosed >= @lowDate and repos.DateClosed <= @highDate)
order by DateAssigned desc;
", lowDate, highDate).ToListAsync();
}
public async Task<IReadOnlyCollection<StdReportEntry>> GetAccountsByDateSoldInAutoIMS(DateTime lowDateTime, DateTime highDateTime)
{
return await GetAccountsWithinDateRange(lowDateTime, highDateTime, "SoldDate");
}
public async Task<IReadOnlyCollection<StdReportEntry>> GetAccountsByDateRepoed(DateTime lowDateTime, DateTime highDateTime)
{
return await GetAccountsWithinDateRange(lowDateTime, highDateTime, "DateRepoed");
}
public async Task<IReadOnlyCollection<StdReportEntry>> GetAccountsByDateAssigned(DateTime lowDateTime, DateTime highDateTime)
{
return await GetAccountsWithinDateRange(lowDateTime, highDateTime, "RepoCompanyAssignmentDate");
}
public async Task<IReadOnlyCollection<StdReportEntry>> GetAccountsByStatusChangeInPeriod(string status, DateTime lowDateTime, DateTime highDateTime)
{
return await GetAccountsWithLatestStatusChangeInPeriod(lowDateTime, highDateTime, status);
}
public async Task<IReadOnlyCollection<StdReportEntry>> GetAccountsByO4RDate(DateTime lowDateTime, DateTime highDateTime)
{
return await GetAccountsWithinDateRange(lowDateTime, highDateTime, "O4RDate");
}
private async Task<IReadOnlyCollection<StdReportEntry>> GetAccountsWithinDateRange(DateTime lowDateTime, DateTime highDateTime, string dateFieldToFilter)
{
var lowDate = new SqlParameter("lowDate", lowDateTime);
var highDate = new SqlParameter("highDate", highDateTime);
return await _context.StandardReportEntries.FromSql(
$@"
select
repos.repoId as RepoId,
repos.Balance as Balance,
repos.AccountNo as AccountNo,
repos.AccountTypeCode as AccountTypeCode,
repos.Bankruptcy as Bankruptcy,
repos.Collector as Collector,
repos.O4RDate as O4RDate,
DATEDIFF(day, Repos.DueToPayDate, CURRENT_TIMESTAMP) as DaysCurrentDelq,
Repos.DaysDelinquent as DaysDelqWhenAdded,
Repos.Status as Status,
(select max(ChangedDate) from RepoStatusChanges where RepoId = repos.RepoId) as MostRecentStatusChangeDate,
DATEDIFF(day, RepoStatusChanges.ChangedDate, CURRENT_TIMESTAMP) as DaysInStatus,
RepoStatusChanges.ChangedDate as StatusChangeDate,
Repos.LstPmtAmt as LastPaymentAmount,
Repos.LastPaymentDate as LastPaymentDate,
Repos.DelinquentAmount as DelinquentAmount,
Collaterals.CollateralId as CollateralId,
RepoCompanySelections.RepoCompanyId as RepoCompanyId,
Collaterals.Year as Year,
Collaterals.Make as Make,
Collaterals.Model as Model,
RepoCompany.Name as RepoCompany,
RepoCompanySelections.DateRepoed as DateRepoed,
RepoCompanySelections.RepoCompanyAssignmentDate as RepoCompanyAssignmentDate,
RepoCompanySelections.RepoType as RepoType,
DATEDIFF(day, RepoCompanySelections.RepoCompanyAssignmentDate, RepoCompanySelections.DateRepoed) as RepoDuration,
AuctionAssignments.AuctionId as AuctionId,
Auctions.Name as AuctionName,
IMSAutoFileData.Status as AutoImsStatus,
IMSAutoFileData.SoldDate as SoldDate,
IMSAutoFileData.DateEnteredAutoIMS as DateEnteredAutoIMS,
IMSAutoFileData.ScheduledSaleDate as ScheduledSaleDate,
IMSAutoFileData.VehicleGrade as Grade, IMSAutoFileData.FloorPriceAccepted as FloorPrice,
IMSAutoFileData.SalePrice as GrossSalePrice,
IMSAutoFileData.GrossPercentFloor as GrossPercentFloor,
IMSAutoFileData.NetPercentFloor as NetPercentFloor,
IMSAutoFileData.TotalCharges as TotalCharges,
Borrowers.IndividualName as IndividualName,
null as FilteredStatus,
null as FilteredStatusChangeDate
From repos
left join RepoStatusChanges on RepoStatusChanges.RepoId = Repos.RepoId
and RepoStatusChanges.ChangedDate = (select max(ChangedDate) from RepoStatusChanges where RepoId = repos.RepoId)
left join Collaterals on Collaterals.RepoId = Repos.RepoId
left join RepoCompanySelections on Collaterals.CollateralId = RepoCompanySelections.CollateralId
left join RepoCompany on RepoCompanySelections.RepoCompanyId = RepoCompany.ID
left join AuctionAssignmentsToCollaterals on Collaterals.CollateralId = AuctionAssignmentsToCollaterals.CollateralId
left join AuctionAssignments on AuctionAssignmentsToCollaterals.AuctionAssignmentId = AuctionAssignments.ID
left join Auctions on Auctions.AuctionID = AuctionAssignments.AuctionId
left join IMSAutoFileData on Repos.RepoId = IMSAutoFileData.RepoId
left join Borrowers on Repos.RepoId = Borrowers.RepoId and Borrowers.OwnershipType = 6
where RepoCompanySelections.DateTimeCreated = (
select max(RepoCompanySelections.DateTimeCreated)
from RepoCompanySelections
where RepoCompanySelections.CollateralId = Collaterals.CollateralId
) and {dateFieldToFilter} >= @lowDate and {dateFieldToFilter} <= @highDate
", lowDate, highDate).Distinct().ToListAsync();
}
private async Task<IReadOnlyCollection<StdReportEntry>> GetAccountsWithLatestStatusChangeInPeriod(DateTime lowDateTime, DateTime highDateTime, string status)
{
var lowDate = new SqlParameter("lowDate", lowDateTime);
var highDate = new SqlParameter("highDate", highDateTime);
var repoStatus = new SqlParameter("repoStatus", status);
return await _context.StandardReportEntries.FromSql(
$@"
select
repos.repoId as RepoId,
repos.Balance as Balance,
repos.AccountNo as AccountNo,
repos.AccountTypeCode as AccountTypeCode,
repos.Bankruptcy as Bankruptcy,
repos.Collector as Collector,
repos.O4RDate as O4RDate,
DATEDIFF(day, Repos.DueToPayDate, CURRENT_TIMESTAMP) as DaysCurrentDelq,
Repos.DaysDelinquent as DaysDelqWhenAdded,
Repos.Status as Status,
(select max(ChangedDate) from RepoStatusChanges where RepoId = repos.RepoId) as MostRecentStatusChangeDate,
DATEDIFF(day, RepoStatusChanges.ChangedDate, CURRENT_TIMESTAMP) as DaysInStatus,
RepoStatusChanges.ChangedDate as StatusChangeDate,
Repos.LstPmtAmt as LastPaymentAmount,
Repos.LastPaymentDate as LastPaymentDate,
Repos.DelinquentAmount as DelinquentAmount,
Collaterals.CollateralId as CollateralId,
RepoCompanySelections.RepoCompanyId as RepoCompanyId,
Collaterals.Year as Year,
Collaterals.Make as Make,
Collaterals.Model as Model,
RepoCompany.Name as RepoCompany,
RepoCompanySelections.DateRepoed as DateRepoed,
RepoCompanySelections.RepoCompanyAssignmentDate as RepoCompanyAssignmentDate,
RepoCompanySelections.RepoType as RepoType,
DATEDIFF(day, RepoCompanySelections.RepoCompanyAssignmentDate, RepoCompanySelections.DateRepoed) as RepoDuration,
AuctionAssignments.AuctionId as AuctionId,
Auctions.Name as AuctionName,
IMSAutoFileData.Status as AutoImsStatus,
IMSAutoFileData.SoldDate as SoldDate,
IMSAutoFileData.DateEnteredAutoIMS as DateEnteredAutoIMS,
IMSAutoFileData.ScheduledSaleDate as ScheduledSaleDate,
IMSAutoFileData.VehicleGrade as Grade, IMSAutoFileData.FloorPriceAccepted as FloorPrice,
IMSAutoFileData.SalePrice as GrossSalePrice,
IMSAutoFileData.GrossPercentFloor as GrossPercentFloor,
IMSAutoFileData.NetPercentFloor as NetPercentFloor,
IMSAutoFileData.TotalCharges as TotalCharges,
Borrowers.IndividualName as IndividualName,
DesiredStatusChange.StatusTo as FilteredStatus,
DesiredStatusChange.ChangedDate as FilteredStatusChangeDate
From repos
left join RepoStatusChanges on RepoStatusChanges.RepoId = Repos.RepoId
and RepoStatusChanges.ChangedDate = (select max(ChangedDate) from RepoStatusChanges where RepoId = repos.RepoId)
left join Collaterals on Collaterals.RepoId = Repos.RepoId
left join RepoCompanySelections on Collaterals.CollateralId = RepoCompanySelections.CollateralId
left join RepoCompany on RepoCompanySelections.RepoCompanyId = RepoCompany.ID
left join AuctionAssignmentsToCollaterals on Collaterals.CollateralId = AuctionAssignmentsToCollaterals.CollateralId
left join AuctionAssignments on AuctionAssignmentsToCollaterals.AuctionAssignmentId = AuctionAssignments.ID
left join Auctions on Auctions.AuctionID = AuctionAssignments.AuctionId
left join IMSAutoFileData on Repos.RepoId = IMSAutoFileData.RepoId
left join Borrowers on Repos.RepoId = Borrowers.RepoId and Borrowers.OwnershipType = 6
inner join RepoStatusChanges DesiredStatusChange on DesiredStatusChange.RepoId = Repos.RepoId
and DesiredStatusChange.StatusTo = @repoStatus
and DesiredStatusChange.ChangedDate >= @lowDate
and DesiredStatusChange.ChangedDate <= @highDate
where RepoCompanySelections.DateTimeCreated = (
select max(RepoCompanySelections.DateTimeCreated)
from RepoCompanySelections
where RepoCompanySelections.CollateralId = Collaterals.CollateralId
)
", lowDate, highDate, repoStatus).Distinct().ToListAsync();
}
}
}
@@ -0,0 +1,41 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public class SavedLocationRepository : BaseRepository, ISavedLocationRepository
{
public SavedLocationRepository(AppDbContext context) : base(context) { }
public async Task<IEnumerable<SavedLocation>> ListAsync()
{
return await _context.SavedLocations.ToListAsync();
}
public async Task<SavedLocation> FindByIdAsync(int id)
{
return await _context.SavedLocations.Where(savedLocation => savedLocation.ID == id).FirstOrDefaultAsync();
}
public async Task<SavedLocation> AddAsync(SavedLocation savedLocation)
{
var result = await _context.SavedLocations.AddAsync(savedLocation);
return result.Entity;
}
public void Update(SavedLocation savedLocation)
{
_context.SavedLocations.Update(savedLocation);
}
public void Remove(SavedLocation savedLocation)
{
_context.Remove(savedLocation);
}
}
}
@@ -0,0 +1,42 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models.Settings;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories.Settings
{
public class AccountTypeRepository : BaseRepository, IAccountTypeRepository
{
public AccountTypeRepository(AppDbContext context) : base(context)
{
}
public async Task<IEnumerable<AccountType>> ListAllAsync()
{
return await _context.AccountTypeCodes.ToListAsync();
}
public async Task AddAsync(AccountType accountTypeCodes)
{
await _context.AccountTypeCodes.AddAsync(accountTypeCodes);
}
public async Task<AccountType> FindByIdAsync(int id)
{
return await _context.AccountTypeCodes.Where(c => c.ID == id).FirstOrDefaultAsync();
}
public void Update(AccountType category)
{
_context.AccountTypeCodes.Update(category);
}
public void Remove(AccountType category)
{
_context.AccountTypeCodes.Remove(category);
}
}
}
@@ -0,0 +1,42 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models.Settings;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories.Settings
{
public class AllowedStatusChangeRepository : BaseRepository, IAllowedStatusChangeRepository
{
public AllowedStatusChangeRepository(AppDbContext context) : base(context)
{
}
public async Task<IEnumerable<AllowedStatusChange>> ListAllAsync()
{
return await _context.AllowedStatusChanges.ToListAsync();
}
public async Task AddAsync(AllowedStatusChange allowedStatusChanges)
{
await _context.AllowedStatusChanges.AddAsync(allowedStatusChanges);
}
public async Task<AllowedStatusChange> FindByIdAsync(int id)
{
return await _context.AllowedStatusChanges.Where(c => c.ID == id).FirstOrDefaultAsync();
}
public void Update(AllowedStatusChange category)
{
_context.AllowedStatusChanges.Update(category);
}
public void Remove(AllowedStatusChange category)
{
_context.AllowedStatusChanges.Remove(category);
}
}
}
@@ -0,0 +1,42 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models.Settings;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories.Settings
{
public class BodyStyleRepository : BaseRepository, IBodyStyleRepository
{
public BodyStyleRepository(AppDbContext context) : base(context)
{
}
public async Task<IEnumerable<BodyStyle>> ListAllAsync()
{
return await _context.BodyStyleCodes.ToListAsync();
}
public async Task AddAsync(BodyStyle bodyStyleCodes)
{
await _context.BodyStyleCodes.AddAsync(bodyStyleCodes);
}
public async Task<BodyStyle> FindByIdAsync(string id)
{
return await _context.BodyStyleCodes.Where(c => c.Code.Equals(id)).FirstOrDefaultAsync();
}
public void Update(BodyStyle category)
{
_context.BodyStyleCodes.Update(category);
}
public void Remove(BodyStyle category)
{
_context.BodyStyleCodes.Remove(category);
}
}
}
@@ -0,0 +1,42 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models.Settings;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories.Settings
{
public class CleaningLevelRepository : BaseRepository, ICleaningLevelRepository
{
public CleaningLevelRepository(AppDbContext context) : base(context)
{
}
public async Task<IEnumerable<CleaningLevel>> ListAllAsync()
{
return await _context.CleaningLevelCodes.ToListAsync();
}
public async Task AddAsync(CleaningLevel cleaningLevelCodes)
{
await _context.CleaningLevelCodes.AddAsync(cleaningLevelCodes);
}
public async Task<CleaningLevel> FindByIdAsync(int id)
{
return await _context.CleaningLevelCodes.Where(c => c.Code == id).FirstOrDefaultAsync();
}
public void Update(CleaningLevel category)
{
_context.CleaningLevelCodes.Update(category);
}
public void Remove(CleaningLevel category)
{
_context.CleaningLevelCodes.Remove(category);
}
}
}
@@ -0,0 +1,42 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models.Settings;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories.Settings
{
public class CollateralTypeRepository : BaseRepository, ICollateralTypeRepository
{
public CollateralTypeRepository(AppDbContext context) : base(context)
{
}
public async Task<IEnumerable<CollateralType>> ListAllAsync()
{
return await _context.CollateralTypes.ToListAsync();
}
public async Task AddAsync(CollateralType collateralTypes)
{
await _context.CollateralTypes.AddAsync(collateralTypes);
}
public async Task<CollateralType> FindByIdAsync(int id)
{
return await _context.CollateralTypes.Where(c => c.ID == id).FirstOrDefaultAsync();
}
public void Update(CollateralType category)
{
_context.CollateralTypes.Update(category);
}
public void Remove(CollateralType category)
{
_context.CollateralTypes.Remove(category);
}
}
}
@@ -0,0 +1,42 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models.Settings;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories.Settings
{
public class CollateralTypeToVehicleTypeRepository : BaseRepository, ICollateralTypeToVehicleTypeRepository
{
public CollateralTypeToVehicleTypeRepository(AppDbContext context) : base(context)
{
}
public async Task<IEnumerable<CollateralTypeToVehicleType>> ListAllAsync()
{
return await _context.CollateralTypesToVehicleTypes.ToListAsync();
}
public async Task AddAsync(CollateralTypeToVehicleType collateralTypesToVehicleTypes)
{
await _context.CollateralTypesToVehicleTypes.AddAsync(collateralTypesToVehicleTypes);
}
public async Task<CollateralTypeToVehicleType> FindByIdAsync(int id)
{
return await _context.CollateralTypesToVehicleTypes.Where(c => c.ID == id).FirstOrDefaultAsync();
}
public void Update(CollateralTypeToVehicleType category)
{
_context.CollateralTypesToVehicleTypes.Update(category);
}
public void Remove(CollateralTypeToVehicleType category)
{
_context.CollateralTypesToVehicleTypes.Remove(category);
}
}
}
@@ -0,0 +1,42 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models.Settings;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories.Settings
{
public class HoldStatusRepository : BaseRepository, IHoldStatusRepository
{
public HoldStatusRepository(AppDbContext context) : base(context)
{
}
public async Task<IEnumerable<HoldStatus>> ListAllAsync()
{
return await _context.HoldStatusCodes.ToListAsync();
}
public async Task AddAsync(HoldStatus holdStatusCodes)
{
await _context.HoldStatusCodes.AddAsync(holdStatusCodes);
}
public async Task<HoldStatus> FindByIdAsync(int id)
{
return await _context.HoldStatusCodes.Where(c => c.Code == id).FirstOrDefaultAsync();
}
public void Update(HoldStatus category)
{
_context.HoldStatusCodes.Update(category);
}
public void Remove(HoldStatus category)
{
_context.HoldStatusCodes.Remove(category);
}
}
}
@@ -0,0 +1,15 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models.Settings;
namespace LCU.Shared.Collections.RepoApiLib.Repositories.Settings
{
public interface IAccountTypeRepository
{
Task<IEnumerable<AccountType>> ListAllAsync();
Task AddAsync(AccountType code);
Task<AccountType> FindByIdAsync(int id);
void Update(AccountType code);
void Remove(AccountType code);
}
}
@@ -0,0 +1,15 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models.Settings;
namespace LCU.Shared.Collections.RepoApiLib.Repositories.Settings
{
public interface IAllowedStatusChangeRepository
{
Task<IEnumerable<AllowedStatusChange>> ListAllAsync();
Task AddAsync(AllowedStatusChange change);
Task<AllowedStatusChange> FindByIdAsync(int id);
void Update(AllowedStatusChange change);
void Remove(AllowedStatusChange change);
}
}
@@ -0,0 +1,15 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models.Settings;
namespace LCU.Shared.Collections.RepoApiLib.Repositories.Settings
{
public interface IBodyStyleRepository
{
Task<IEnumerable<BodyStyle>> ListAllAsync();
Task AddAsync(BodyStyle code);
Task<BodyStyle> FindByIdAsync(string id);
void Update(BodyStyle code);
void Remove(BodyStyle code);
}
}
@@ -0,0 +1,15 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models.Settings;
namespace LCU.Shared.Collections.RepoApiLib.Repositories.Settings
{
public interface ICleaningLevelRepository
{
Task<IEnumerable<CleaningLevel>> ListAllAsync();
Task AddAsync(CleaningLevel code);
Task<CleaningLevel> FindByIdAsync(int id);
void Update(CleaningLevel code);
void Remove(CleaningLevel code);
}
}
@@ -0,0 +1,15 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models.Settings;
namespace LCU.Shared.Collections.RepoApiLib.Repositories.Settings
{
public interface ICollateralTypeRepository
{
Task<IEnumerable<CollateralType>> ListAllAsync();
Task AddAsync(CollateralType type);
Task<CollateralType> FindByIdAsync(int id);
void Update(CollateralType type);
void Remove(CollateralType type);
}
}
@@ -0,0 +1,15 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models.Settings;
namespace LCU.Shared.Collections.RepoApiLib.Repositories.Settings
{
public interface ICollateralTypeToVehicleTypeRepository
{
Task<IEnumerable<CollateralTypeToVehicleType>> ListAllAsync();
Task AddAsync(CollateralTypeToVehicleType type);
Task<CollateralTypeToVehicleType> FindByIdAsync(int id);
void Update(CollateralTypeToVehicleType type);
void Remove(CollateralTypeToVehicleType type);
}
}
@@ -0,0 +1,15 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models.Settings;
namespace LCU.Shared.Collections.RepoApiLib.Repositories.Settings
{
public interface IHoldStatusRepository
{
Task<IEnumerable<HoldStatus>> ListAllAsync();
Task AddAsync(HoldStatus code);
Task<HoldStatus> FindByIdAsync(int id);
void Update(HoldStatus code);
void Remove(HoldStatus code);
}
}
@@ -0,0 +1,15 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models.Settings;
namespace LCU.Shared.Collections.RepoApiLib.Repositories.Settings
{
public interface ILoanCategoryRepository
{
Task<IEnumerable<LoanCategory>> ListAllAsync();
Task AddAsync(LoanCategory category);
Task<LoanCategory> FindByIdAsync(int id);
void Update(LoanCategory category);
void Remove(LoanCategory category);
}
}
@@ -0,0 +1,15 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models.Settings;
namespace LCU.Shared.Collections.RepoApiLib.Repositories.Settings
{
public interface ILocationTypeRepository
{
Task<IEnumerable<LocationType>> ListAllAsync();
Task AddAsync(LocationType code);
Task<LocationType> FindByIdAsync(int id);
void Update(LocationType code);
void Remove(LocationType code);
}
}
@@ -0,0 +1,15 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models.Settings;
namespace LCU.Shared.Collections.RepoApiLib.Repositories.Settings
{
public interface IVehicleTypeRepository
{
Task<IEnumerable<VehicleType>> ListAllAsync();
Task AddAsync(VehicleType code);
Task<VehicleType> FindByIdAsync(string id);
void Update(VehicleType code);
void Remove(VehicleType code);
}
}
@@ -0,0 +1,42 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models.Settings;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories.Settings
{
public class LoanCategoryRepository : BaseRepository, ILoanCategoryRepository
{
public LoanCategoryRepository(AppDbContext context) : base(context)
{
}
public async Task<IEnumerable<LoanCategory>> ListAllAsync()
{
return await _context.LoanCategories.ToListAsync();
}
public async Task AddAsync(LoanCategory loanCategories)
{
await _context.LoanCategories.AddAsync(loanCategories);
}
public async Task<LoanCategory> FindByIdAsync(int id)
{
return await _context.LoanCategories.Where(c => c.ID == id).FirstOrDefaultAsync();
}
public void Update(LoanCategory category)
{
_context.LoanCategories.Update(category);
}
public void Remove(LoanCategory category)
{
_context.LoanCategories.Remove(category);
}
}
}
@@ -0,0 +1,42 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models.Settings;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories.Settings
{
public class LocationTypeRepository : BaseRepository, ILocationTypeRepository
{
public LocationTypeRepository(AppDbContext context) : base(context)
{
}
public async Task<IEnumerable<LocationType>> ListAllAsync()
{
return await _context.LocationTypeCodes.ToListAsync();
}
public async Task AddAsync(LocationType locationTypeCodes)
{
await _context.LocationTypeCodes.AddAsync(locationTypeCodes);
}
public async Task<LocationType> FindByIdAsync(int id)
{
return await _context.LocationTypeCodes.Where(c => c.Code == id).FirstOrDefaultAsync();
}
public void Update(LocationType category)
{
_context.LocationTypeCodes.Update(category);
}
public void Remove(LocationType category)
{
_context.LocationTypeCodes.Remove(category);
}
}
}
@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models.Settings;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories.Settings
{
public class VehicleTypeRepository : BaseRepository, IVehicleTypeRepository
{
public VehicleTypeRepository(AppDbContext context) : base(context)
{
}
public async Task<IEnumerable<VehicleType>> ListAllAsync()
{
return await _context.VehicleTypeCodes.ToListAsync();
}
public async Task AddAsync(VehicleType vehicleTypeCodes)
{
await _context.VehicleTypeCodes.AddAsync(vehicleTypeCodes);
}
public async Task<VehicleType> FindByIdAsync(string id)
{
return await _context.VehicleTypeCodes.Where(c => c.Code.Equals(id)).FirstOrDefaultAsync();
}
public void Update(VehicleType category)
{
_context.VehicleTypeCodes.Update(category);
}
public void Remove(VehicleType category)
{
_context.VehicleTypeCodes.Remove(category);
}
}
}
@@ -0,0 +1,20 @@
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Persistence;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public class UnitOfWork : IUnitOfWork
{
private readonly AppDbContext _context;
public UnitOfWork(AppDbContext context)
{
_context = context;
}
public async Task CompleteAsync()
{
await _context.SaveChangesAsync();
}
}
}
@@ -0,0 +1,42 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.Shared.Collections.RepoApiLib.Persistence;
using Microsoft.EntityFrameworkCore;
namespace LCU.Shared.Collections.RepoApiLib.Repositories
{
public class VehicleFloorPricingParametersRepository : BaseRepository, IVehicleFloorPricingParametersRepository
{
public VehicleFloorPricingParametersRepository(AppDbContext context) : base(context)
{
}
public async Task<IEnumerable<VehicleFloorPricingParameters>> ListAllAsync()
{
return await _context.VehicleFloorPricingParameters.ToListAsync();
}
public async Task AddAsync(VehicleFloorPricingParameters parameters)
{
await _context.VehicleFloorPricingParameters.AddAsync(parameters);
}
public async Task<VehicleFloorPricingParameters> FindByIdAsync(int id)
{
return await Queryable.Where<VehicleFloorPricingParameters>(_context.VehicleFloorPricingParameters, c => c.Id == id).FirstOrDefaultAsync();
}
public void Update(VehicleFloorPricingParameters parameters)
{
_context.VehicleFloorPricingParameters.Update(parameters);
}
public void Remove(VehicleFloorPricingParameters parameters)
{
_context.VehicleFloorPricingParameters.Remove(parameters);
}
}
}