Adding
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
namespace ReserveManagementSystemLib.Configuration
|
||||
{
|
||||
public class CoreApiConfiguration
|
||||
{
|
||||
public string ClientName { get; set; }
|
||||
public string ApiTimeOutInSeconds { get; set; }
|
||||
public string BaseUrl { get; set; }
|
||||
public string GetIndirectLoansByPostedDate { get; set; }
|
||||
public string GetClosedLoansByPostedDate { get; set; }
|
||||
public string GetClosedIndirectLoansWithDetailByPostedDate { get; set; }
|
||||
public string PostMonetaryTransactions { get; set; }
|
||||
public string PutDealerOriginalBalance { get; set; }
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
namespace ReserveManagementSystemLib.Configuration
|
||||
{
|
||||
public class RmsApiConfiguration
|
||||
{
|
||||
public string DefaultImportStartDate { get; set; }
|
||||
public int DefaultBatchSize { get; set; }
|
||||
public string DefaultConvertedLoanPostDate { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
namespace ReserveManagementSystemLib.Enums
|
||||
{
|
||||
public enum ImportType
|
||||
{
|
||||
Active,
|
||||
Closed
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
namespace ReserveManagementSystemLib.Helpers
|
||||
{
|
||||
public static class StringExtensions
|
||||
{
|
||||
public static string Truncate(this string inputString, int numberOfCharacters)
|
||||
{
|
||||
if (inputString.Length <= numberOfCharacters)
|
||||
{
|
||||
return inputString;
|
||||
}
|
||||
else
|
||||
{
|
||||
return inputString.Substring(0, numberOfCharacters);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
using FluentValidation;
|
||||
using FluentValidation.Results;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using ReserveManagementSystemLib.Models;
|
||||
|
||||
namespace ReserveManagementSystemLib.Helpers
|
||||
{
|
||||
public class ValidationHelper
|
||||
{
|
||||
|
||||
public static List<ValidationFailure> SetValidationErrors(Loan loanInfo)
|
||||
{
|
||||
var validator = GetValidatorForModel();
|
||||
var editContext = new EditContext(loanInfo);
|
||||
|
||||
var context = new ValidationContext<object>(editContext.Model);
|
||||
var validationResults = validator.Validate(context);
|
||||
|
||||
return new List<ValidationFailure>(validationResults.Errors);
|
||||
}
|
||||
|
||||
private static IValidator GetValidatorForModel()
|
||||
{
|
||||
LoanValidator baseclass = new LoanValidator();
|
||||
var modelValidatorInstance = (IValidator)Activator.CreateInstance(baseclass.GetType());
|
||||
|
||||
return modelValidatorInstance;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
namespace ReserveManagementSystemLib.Models
|
||||
{
|
||||
public class AuditHistory
|
||||
{
|
||||
[Key]
|
||||
public int AuditId { get; set; }
|
||||
public int? LoanId { get; set; }
|
||||
public string MemberNumber { get; set; }
|
||||
public string LoanNumber { get; set; }
|
||||
public string ModifiedBy { get; set; }
|
||||
public DateTime ModifiedDate { get; set; }
|
||||
public string ActivityType { get; set; }
|
||||
public string OldValue { get; set; }
|
||||
public string NewValue { get; set; }
|
||||
public string AuditDescription { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
namespace ReserveManagementSystemLib.Models
|
||||
{
|
||||
public class CalculationConfig
|
||||
{
|
||||
public readonly Loan _loanData;
|
||||
|
||||
public CalculationConfig(Loan loanData)
|
||||
{
|
||||
_loanData = loanData;
|
||||
}
|
||||
|
||||
public Loan LoanData() { return _loanData; }
|
||||
|
||||
public decimal BuydownRateDifference() { return _loanData.BuyRate - _loanData.ContractRate; }
|
||||
|
||||
public decimal BuyFinanceCharge { get; set; }
|
||||
|
||||
public decimal ContractFinanceCharge { get; set; }
|
||||
|
||||
public int DaysToFirstPmt() { return (_loanData.FirstPmtDate - _loanData.LoanDate).Days - 30 > 0 ? (_loanData.FirstPmtDate - _loanData.LoanDate).Days - 30 : 0; }
|
||||
|
||||
public decimal ReserveDiscount() { return _loanData.LoanType?.ReserveDiscount ?? 25M; }
|
||||
|
||||
public decimal FlatFeePercent() { return _loanData.LoanType?.FlatFeePercent ?? 1M; }
|
||||
|
||||
public decimal NoReserveThreshold() { return _loanData.LoanType?.NoReserveThreshold ?? 0.25M; }
|
||||
|
||||
public decimal StdRate() { return (_loanData.ContractRate - _loanData.BuyRate); }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
namespace ReserveManagementSystemLib.Models
|
||||
{
|
||||
public class Dealer
|
||||
{
|
||||
|
||||
public string DealerCode { get; set; }
|
||||
|
||||
string _dealerName;
|
||||
public string Name { get { return _dealerName?.ToUpper(); } set => _dealerName = value?.ToUpper(); }
|
||||
|
||||
public string DealerGroupCode { get; set; }
|
||||
|
||||
public string DealerAccountNumber { get; set; }
|
||||
|
||||
[Key]
|
||||
public string DealerOrganizationNumber { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is Dealer dealer &&
|
||||
DealerCode == dealer.DealerCode &&
|
||||
Name == dealer.Name?.ToUpper() &&
|
||||
DealerAccountNumber == dealer.DealerAccountNumber &&
|
||||
DealerOrganizationNumber == dealer.DealerOrganizationNumber;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(DealerCode, DealerAccountNumber, DealerOrganizationNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
namespace ReserveManagementSystemLib.Models
|
||||
{
|
||||
public class Import
|
||||
{
|
||||
[Key]
|
||||
public int ImportId { get; set; }
|
||||
|
||||
public DateTime StartDate { get; set; }
|
||||
|
||||
public DateTime? EndDate { get; set; }
|
||||
|
||||
public int RecordCount { get; set; }
|
||||
|
||||
public int RecordsSaved { get; set; }
|
||||
|
||||
public bool Success { get; set; }
|
||||
|
||||
public string FileName { get; set; }
|
||||
|
||||
public string ImportType { get; set; }
|
||||
}
|
||||
}
|
||||
+204
@@ -0,0 +1,204 @@
|
||||
using FluentValidation;
|
||||
using FluentValidation.Results;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ReserveManagementSystemLib.Models
|
||||
{
|
||||
public class Loan
|
||||
{
|
||||
[Key]
|
||||
public int LoanId { get; set; }
|
||||
|
||||
public int ImportId { get; set; }
|
||||
|
||||
public string MemberNumber { get; set; }
|
||||
|
||||
public string LoanNumber { get; set; }
|
||||
|
||||
public string MemberLastName { get; set; }
|
||||
|
||||
public string MemberFirstName { get; set; }
|
||||
|
||||
public string MemberInitial { get; set; }
|
||||
|
||||
public string DealerOrganizationNumber { get; set; }
|
||||
|
||||
public DateTime LoanDate { get; set; }
|
||||
|
||||
public DateTime PostedDate { get; set; }
|
||||
|
||||
public DateTime FirstPmtDate { get; set; }
|
||||
|
||||
public DateTime FinalPmtDate { get; set; }
|
||||
|
||||
public decimal LoanAmount { get; set; }
|
||||
|
||||
public decimal BuyRate { get; set; }
|
||||
|
||||
public decimal ContractRate { get; set; }
|
||||
|
||||
public decimal MonthlyPmt { get; set; }
|
||||
|
||||
public string LoanTypeId { get; set; }
|
||||
|
||||
public int Term { get; set; }
|
||||
|
||||
public decimal ReserveAmount { get; set; }
|
||||
|
||||
public bool FlatFeePaid { get; set; }
|
||||
|
||||
public decimal? ChargeBack { get; set; }
|
||||
|
||||
public string ChargebackMessage { get; set; }
|
||||
|
||||
public byte? RemainingMonthsAtClose { get; set; }
|
||||
|
||||
public DateTime? PaidLoanDate { get; set; }
|
||||
|
||||
public string ReserveMessage { get; set; }
|
||||
|
||||
public bool ActionRequired { get; set; }
|
||||
|
||||
public DateTime? StatementDate { get; set; }
|
||||
|
||||
public decimal? Adjustment { get; set; }
|
||||
|
||||
public string LoanStatus { get; set; }
|
||||
|
||||
public DateTime? ExportedReserveDate { get; set; }
|
||||
|
||||
public DateTime? ExportedChargebackDate { get; set; }
|
||||
|
||||
public string ApplicationId { get; set; }
|
||||
|
||||
public bool Warranty { get; set; }
|
||||
|
||||
public bool Gap { get; set; }
|
||||
|
||||
public bool CreditLife { get; set; }
|
||||
|
||||
public bool CreditDisability { get; set; }
|
||||
|
||||
public bool Mbp { get; set; }
|
||||
|
||||
public string AccountType { get; set; }
|
||||
|
||||
[ForeignKey("DealerOrganizationNumber")]
|
||||
public Dealer Dealer { get; set; }
|
||||
|
||||
[ForeignKey("LoanTypeId")]
|
||||
public LoanType LoanType { get; set; }
|
||||
|
||||
public Vehicle Vehicle { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public List<ValidationFailure> ValidationErrors { get; set; }
|
||||
|
||||
public bool HasSameReserve(object obj)
|
||||
{
|
||||
return obj is Loan loan &&
|
||||
LoanDate == loan.LoanDate &&
|
||||
Term == loan.Term &&
|
||||
FirstPmtDate == loan.FirstPmtDate &&
|
||||
FinalPmtDate == loan.FinalPmtDate &&
|
||||
LoanAmount == loan.LoanAmount &&
|
||||
LoanTypeId == loan.LoanTypeId &&
|
||||
BuyRate == loan.BuyRate &&
|
||||
ContractRate == loan.ContractRate;
|
||||
}
|
||||
|
||||
public bool IsBoatLoan(object obj)
|
||||
{
|
||||
return obj is Loan loan &&
|
||||
AccountType == "DL09" || AccountType == "DL10" || AccountType == "DL11" || AccountType == "DL12";
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is Loan loan &&
|
||||
MemberNumber == loan.MemberNumber &&
|
||||
LoanNumber == loan.LoanNumber &&
|
||||
MemberLastName == loan.MemberLastName &&
|
||||
MemberFirstName == loan.MemberFirstName &&
|
||||
MemberInitial == loan.MemberInitial &&
|
||||
DealerOrganizationNumber == loan.DealerOrganizationNumber &&
|
||||
LoanDate == loan.LoanDate &&
|
||||
PostedDate == loan.PostedDate &&
|
||||
Term == loan.Term &&
|
||||
FirstPmtDate == loan.FirstPmtDate &&
|
||||
FinalPmtDate == loan.FinalPmtDate &&
|
||||
LoanAmount == loan.LoanAmount &&
|
||||
BuyRate == loan.BuyRate &&
|
||||
ContractRate == loan.ContractRate &&
|
||||
MonthlyPmt == loan.MonthlyPmt &&
|
||||
LoanTypeId == loan.LoanTypeId &&
|
||||
ApplicationId == loan.ApplicationId &&
|
||||
Warranty == loan.Warranty &&
|
||||
Gap == loan.Gap &&
|
||||
Mbp == loan.Mbp &&
|
||||
CreditLife == loan.CreditLife &&
|
||||
CreditDisability == loan.CreditDisability &&
|
||||
ActionRequired == loan.ActionRequired;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
HashCode hash = new HashCode();
|
||||
hash.Add(MemberNumber);
|
||||
hash.Add(LoanNumber);
|
||||
hash.Add(MemberLastName);
|
||||
hash.Add(MemberFirstName);
|
||||
hash.Add(MemberInitial);
|
||||
hash.Add(DealerOrganizationNumber);
|
||||
hash.Add(LoanDate);
|
||||
hash.Add(PostedDate);
|
||||
hash.Add(FirstPmtDate);
|
||||
hash.Add(FinalPmtDate);
|
||||
hash.Add(LoanAmount);
|
||||
hash.Add(BuyRate);
|
||||
hash.Add(ContractRate);
|
||||
hash.Add(MonthlyPmt);
|
||||
hash.Add(LoanTypeId);
|
||||
hash.Add(ApplicationId);
|
||||
hash.Add(Warranty);
|
||||
hash.Add(Gap);
|
||||
hash.Add(Mbp);
|
||||
hash.Add(CreditLife);
|
||||
hash.Add(CreditDisability);
|
||||
hash.Add(ActionRequired);
|
||||
return hash.ToHashCode();
|
||||
}
|
||||
}
|
||||
public class LoanValidator : AbstractValidator<Loan>
|
||||
{
|
||||
public LoanValidator()
|
||||
{
|
||||
|
||||
RuleFor(m => m.LoanTypeId).NotEmpty().WithMessage("Loan type cannot be empty!");
|
||||
RuleFor(m => m.DealerOrganizationNumber).NotEmpty().WithMessage("Dealer Organization Number cannot be empty!");
|
||||
When(m => m.Dealer != null && string.IsNullOrEmpty(m.Dealer.DealerCode), () =>
|
||||
{
|
||||
RuleFor(m => m.Dealer.DealerCode).NotEmpty().WithMessage("Dealer Code cannot be empty!");
|
||||
|
||||
});
|
||||
|
||||
When(m => m.Dealer != null && string.IsNullOrEmpty(m.Dealer.DealerAccountNumber), () =>
|
||||
{
|
||||
RuleFor(m => m.Dealer.DealerAccountNumber).NotEmpty().WithMessage("Dealer Account Number cannot be empty!");
|
||||
});
|
||||
|
||||
When(m => m.Dealer != null && string.IsNullOrEmpty(m.Dealer.Name), () =>
|
||||
{
|
||||
RuleFor(m => m.Dealer.Name).NotEmpty().WithMessage("Dealer Name cannot be empty!");
|
||||
});
|
||||
|
||||
When(m => m.Vehicle != null && string.IsNullOrEmpty(m.Vehicle.VINNumber), () =>
|
||||
{
|
||||
RuleFor(m => m.Vehicle.VINNumber).NotEmpty().WithMessage("VIN cannot be empty!");
|
||||
});
|
||||
|
||||
RuleFor(m => m.LoanDate).LessThanOrEqualTo(m => m.FirstPmtDate).WithMessage("First Payment Date cannot be before Loan Date!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
namespace ReserveManagementSystemLib.Models
|
||||
{
|
||||
public class LoanChargeback
|
||||
{
|
||||
public decimal ChargebackAmount { get; set; }
|
||||
|
||||
public string ChargebackTypeMessage { get; set; }
|
||||
|
||||
public byte? RemainingMonthsAtClose { get; set; }
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
namespace ReserveManagementSystemLib.Models
|
||||
{
|
||||
public class LoanChargebackInput
|
||||
{
|
||||
public DateTime LoanDate { get; set; }
|
||||
|
||||
public DateTime FirstPmtDate { get; set; }
|
||||
|
||||
public DateTime FinalPmtDate { get; set; }
|
||||
|
||||
public string LoanType { get; set; }
|
||||
|
||||
public decimal ReserveAmount { get; set; }
|
||||
|
||||
public DateTime? PaidLoanDate { get; set; }
|
||||
|
||||
public int Term { get; set; }
|
||||
|
||||
public string AccountType { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
namespace ReserveManagementSystemLib.Models
|
||||
{
|
||||
public class LoanFilter
|
||||
{
|
||||
public bool? ActionRequired { get; set; }
|
||||
|
||||
public string DealerCodeText { get; set; }
|
||||
|
||||
public string MemberNumberText { get; set; }
|
||||
|
||||
public string MemberNameText { get; set; }
|
||||
|
||||
public string LoanNumberText { get; set; }
|
||||
|
||||
public string ApplicationIdText { get; set; }
|
||||
|
||||
public int? ImportId { get; set; }
|
||||
|
||||
public DateTime? LoanDateStart { get; set; }
|
||||
|
||||
public DateTime? LoanDateEnd { get; set; }
|
||||
|
||||
public int PageIndex { get; set; }
|
||||
|
||||
public int MaxRecordsPerPage { get; set; }
|
||||
|
||||
public int MaxPagesPerRange { get; set; }
|
||||
|
||||
public string SortField { get; set; }
|
||||
|
||||
public string SortDirection { get; set; }
|
||||
|
||||
public IQueryable<Loan> ApplyFilter(IQueryable<Loan> query)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(MemberNumberText))
|
||||
{
|
||||
query = query.Where(x => x.MemberNumber.Contains(this.MemberNumberText));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(MemberNameText))
|
||||
{
|
||||
query = query.Where(x => x.MemberFirstName.Contains(this.MemberNameText.ToUpper()) || x.MemberLastName.Contains(this.MemberNameText.ToUpper()));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(LoanNumberText))
|
||||
{
|
||||
query = query.Where(x => x.LoanNumber.Contains(this.LoanNumberText));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(ApplicationIdText))
|
||||
{
|
||||
query = query.Where(x => x.ApplicationId.Contains(this.ApplicationIdText));
|
||||
}
|
||||
|
||||
if (ImportId.HasValue)
|
||||
{
|
||||
query = query.Where(x => x.ImportId == ImportId.Value);
|
||||
}
|
||||
|
||||
if (ActionRequired.HasValue && !string.IsNullOrEmpty(ActionRequired.ToString()))
|
||||
{
|
||||
query = query.Where(x => x.ActionRequired == (this.ActionRequired));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(DealerCodeText))
|
||||
{
|
||||
query = query.Where(x => x.Dealer.DealerCode == (this.DealerCodeText));
|
||||
}
|
||||
|
||||
if (LoanDateStart.HasValue || LoanDateEnd.HasValue)
|
||||
{
|
||||
if (LoanDateStart.HasValue && LoanDateEnd.HasValue)
|
||||
{
|
||||
query = query.Where(x => x.LoanDate >= LoanDateStart.Value && x.LoanDate <= LoanDateEnd.Value);
|
||||
}
|
||||
else if (LoanDateStart.HasValue)
|
||||
{
|
||||
query = query.Where(x => x.LoanDate >= LoanDateStart.Value);
|
||||
}
|
||||
else if (LoanDateEnd.HasValue)
|
||||
{
|
||||
query = query.Where(x => x.LoanDate <= LoanDateEnd.Value);
|
||||
}
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
namespace ReserveManagementSystemLib.Models
|
||||
{
|
||||
public class LoanReserve
|
||||
{
|
||||
public decimal ReserveAmount { get; set;}
|
||||
|
||||
public string ReserveTypeMessage { get; set; }
|
||||
|
||||
public bool FlatFeePaid { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
namespace ReserveManagementSystemLib.Models
|
||||
{
|
||||
public class LoanReserveInput
|
||||
{
|
||||
public DateTime LoanDate { get; set; }
|
||||
|
||||
public DateTime FirstPmtDate { get; set; }
|
||||
|
||||
public decimal LoanAmount { get; set; }
|
||||
|
||||
public decimal BuyRate { get; set; }
|
||||
|
||||
public decimal ContractRate { get; set; }
|
||||
|
||||
public int OriginalTermInDays { get; set; }
|
||||
|
||||
public string LoanType { get; set; }
|
||||
|
||||
public string AccountType { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
namespace ReserveManagementSystemLib.Models
|
||||
{
|
||||
public class LoanType
|
||||
{
|
||||
[Key]
|
||||
public string LoanTypeId{ get; set; }
|
||||
|
||||
public string LoanComment { get; set; }
|
||||
|
||||
public string ChargebackMethod { get; set; }
|
||||
|
||||
public short NoChargebackDays { get; set; }
|
||||
|
||||
public short NoChargebackPayments { get; set; }
|
||||
|
||||
public decimal ReserveDiscount { get; set; }
|
||||
|
||||
public decimal FlatFeePercent { get; set; }
|
||||
|
||||
public decimal NoReserveThreshold { get; set; }
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
namespace ReserveManagementSystemLib.Models
|
||||
{
|
||||
public class MinorAccountType
|
||||
{
|
||||
[Key]
|
||||
public int MinorAccountTypeId{ get; set; }
|
||||
|
||||
public string AccountType { get; set; }
|
||||
|
||||
public string GeneralLedgerAccountNumber { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
namespace ReserveManagementSystemLib.Models
|
||||
{
|
||||
public class PaginatedListResponse
|
||||
{
|
||||
public List<Loan> LoanList { get; set; }
|
||||
|
||||
public int PageIndex { get; set; }
|
||||
|
||||
public int TotalPages { get; set; }
|
||||
|
||||
public int TotalItems { get; set; }
|
||||
|
||||
public int FirstPage { get; set; }
|
||||
|
||||
public int LastPage { get; set; }
|
||||
|
||||
public int PageRangeSize { get; set; }
|
||||
|
||||
public PaginatedListResponse() {}
|
||||
|
||||
public void SetFirstAndLastPageToShow()
|
||||
{
|
||||
if (TotalPages < PageRangeSize) { PageRangeSize = TotalPages; }
|
||||
var half = PageRangeSize / 2; //this should be set to an odd number to evenly set page range
|
||||
if (PageIndex - half <= 0)
|
||||
{
|
||||
FirstPage = 1;
|
||||
LastPage = (PageRangeSize > TotalPages) ? TotalPages : PageRangeSize;
|
||||
}
|
||||
else if (PageIndex == TotalPages || PageIndex + half > TotalPages)
|
||||
{
|
||||
FirstPage = TotalPages - PageRangeSize + 1;
|
||||
LastPage = TotalPages;
|
||||
}
|
||||
else //increment page range slightly by the half difference
|
||||
{
|
||||
FirstPage = PageIndex - half;
|
||||
LastPage = PageIndex + half;
|
||||
}
|
||||
}
|
||||
|
||||
public PaginatedListResponse(List<Loan> items, int count, int pageIndex, int pageSize, int pageRangeSize)
|
||||
{
|
||||
PageIndex = pageIndex;
|
||||
TotalItems = count;
|
||||
TotalPages = (int)Math.Ceiling(count / (double)pageSize);
|
||||
PageRangeSize = pageRangeSize;
|
||||
|
||||
SetFirstAndLastPageToShow();
|
||||
List<Loan> loanList = new List<Loan>();
|
||||
loanList.AddRange(items);
|
||||
LoanList = loanList;
|
||||
}
|
||||
|
||||
public bool HasPreviousPage
|
||||
{
|
||||
get
|
||||
{
|
||||
return (PageIndex > 1);
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasNextPage
|
||||
{
|
||||
get
|
||||
{
|
||||
return (PageIndex < TotalPages);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<PaginatedListResponse> CreateListAsync(IQueryable<Loan> source, int pageIndex, int pageSize, int pageRangeSize)
|
||||
{
|
||||
var count = source.Count();
|
||||
var items = await source.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToListAsync();
|
||||
return new PaginatedListResponse(items, count, pageIndex, pageSize, pageRangeSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
namespace ReserveManagementSystemLib.Models
|
||||
{
|
||||
public class RmsActiveImportRequest
|
||||
{
|
||||
public string ImportDateTime { get; set; }
|
||||
public bool SkipExport { get; set; }
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
namespace ReserveManagementSystemLib.Models
|
||||
{
|
||||
public class Vehicle
|
||||
{
|
||||
[Key]
|
||||
public int VehicleId { get; set; }
|
||||
|
||||
public int? LoanId { get; set; }
|
||||
|
||||
public string VINNumber { get; set; }
|
||||
|
||||
public string Make { get; set; }
|
||||
|
||||
public string Model { get; set; }
|
||||
|
||||
public string Year { get; set; }
|
||||
|
||||
public double Mileage { get; set; }
|
||||
|
||||
public string Color { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is Vehicle vehicle &&
|
||||
VINNumber == vehicle.VINNumber &&
|
||||
Make == vehicle.Make &&
|
||||
Model == vehicle.Model &&
|
||||
Year == vehicle.Year &&
|
||||
Mileage == vehicle.Mileage &&
|
||||
Color == vehicle.Color;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(VINNumber, Make, Model, Year, Mileage, Color);
|
||||
}
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
using ReserveManagementSystemLib.Models;
|
||||
|
||||
namespace ReserveManagementSystemLib.Persistence
|
||||
{
|
||||
public class AppDbContext : DbContext
|
||||
{
|
||||
public DbSet<Loan> Loans { get; set; }
|
||||
|
||||
public DbSet<LoanType> LoanTypes { get; set; }
|
||||
|
||||
public DbSet<Import> Imports { get; set; }
|
||||
|
||||
public DbSet<AuditHistory> AuditHistories { get; set; }
|
||||
|
||||
public DbSet<Dealer> Dealers { get; set; }
|
||||
|
||||
public DbSet<Vehicle> Vehicles { get; set; }
|
||||
|
||||
public DbSet<MinorAccountType> MinorAccountTypes { get; set; }
|
||||
|
||||
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
base.OnModelCreating(builder);
|
||||
|
||||
builder.Entity<Loan>().ToTable("Loan");
|
||||
|
||||
builder.Entity<LoanType>().ToTable("LoanType");
|
||||
|
||||
builder.Entity<Import>().ToTable("Import");
|
||||
|
||||
builder.Entity<AuditHistory>().ToTable("LoanAudit");
|
||||
|
||||
builder.Entity<Dealer>().ToTable("Dealer");
|
||||
|
||||
builder.Entity<Vehicle>().ToTable("Vehicle");
|
||||
|
||||
builder.Entity<MinorAccountType>().ToTable("MinorAccountType");
|
||||
}
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
using ReserveManagementSystemLib.Models;
|
||||
using ReserveManagementSystemLib.Persistence;
|
||||
|
||||
namespace ReserveManagementSystemLib.Repositories
|
||||
{
|
||||
public class AuditHistoryRepository: BaseRepository, IAuditHistoryRepository
|
||||
{
|
||||
public AuditHistoryRepository(AppDbContext context) : base(context) { }
|
||||
|
||||
public IQueryable<AuditHistory> GetAll()
|
||||
{
|
||||
return _context.AuditHistories;
|
||||
}
|
||||
|
||||
public async Task<AuditHistory> FindByIdAsync(int id)
|
||||
{
|
||||
return await _context.AuditHistories.FirstOrDefaultAsync(l => l.AuditId == id);
|
||||
}
|
||||
|
||||
public async Task<AuditHistory> AddHistoryAsync(AuditHistory history)
|
||||
{
|
||||
try
|
||||
{
|
||||
var newAudit = await _context.AuditHistories.AddAsync(history);
|
||||
await _context.SaveChangesAsync();
|
||||
return newAudit.Entity;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure to add audit history");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<int> AddHistoriesAsync(List<AuditHistory> histories)
|
||||
{
|
||||
await _context.AuditHistories.AddRangeAsync(histories);
|
||||
return await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
using ReserveManagementSystemLib.Persistence;
|
||||
|
||||
namespace ReserveManagementSystemLib.Repositories
|
||||
{
|
||||
public class BaseRepository
|
||||
{
|
||||
protected readonly AppDbContext _context;
|
||||
|
||||
public BaseRepository(AppDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
using ReserveManagementSystemLib.Models;
|
||||
using ReserveManagementSystemLib.Persistence;
|
||||
|
||||
namespace ReserveManagementSystemLib.Repositories
|
||||
{
|
||||
public class DealerRepository : BaseRepository, IDealerRepository
|
||||
{
|
||||
public DealerRepository(AppDbContext context) : base(context) { }
|
||||
|
||||
public async Task<Dealer> FindByCodeAsync(string code)
|
||||
{
|
||||
return await _context.Dealers.FirstOrDefaultAsync(d => d.DealerCode == code);
|
||||
}
|
||||
|
||||
public IQueryable<Dealer> GetAll()
|
||||
{
|
||||
return _context.Dealers;
|
||||
}
|
||||
|
||||
public async Task<Dealer> AddDealerAsync(Dealer dealer)
|
||||
{
|
||||
try
|
||||
{
|
||||
var newDealer = await _context.Dealers.AddAsync(dealer);
|
||||
await _context.SaveChangesAsync();
|
||||
return newDealer.Entity;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure to add dealer.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<int> UpdateDealersAsync(List<Dealer> dealers)
|
||||
{
|
||||
_context.Dealers.UpdateRange(dealers);
|
||||
return await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task<int> AddDealersAsync(List<Dealer> dealers)
|
||||
{
|
||||
_context.Dealers.AddRange(dealers);
|
||||
return await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
using ReserveManagementSystemLib.Models;
|
||||
|
||||
namespace ReserveManagementSystemLib.Repositories
|
||||
{
|
||||
public interface IAuditHistoryRepository
|
||||
{
|
||||
IQueryable<AuditHistory> GetAll();
|
||||
|
||||
Task<AuditHistory> FindByIdAsync(int id);
|
||||
|
||||
Task<AuditHistory> AddHistoryAsync(AuditHistory history);
|
||||
|
||||
Task<int> AddHistoriesAsync(List<AuditHistory> histories);
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
using ReserveManagementSystemLib.Models;
|
||||
|
||||
namespace ReserveManagementSystemLib.Repositories
|
||||
{
|
||||
public interface IDealerRepository
|
||||
{
|
||||
Task<Dealer> FindByCodeAsync(string dealerCode);
|
||||
|
||||
IQueryable<Dealer> GetAll();
|
||||
|
||||
Task<Dealer> AddDealerAsync(Dealer dealer);
|
||||
|
||||
Task<int> UpdateDealersAsync(List<Dealer> dealers);
|
||||
|
||||
Task<int> AddDealersAsync(List<Dealer> dealers);
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
using ReserveManagementSystemLib.Enums;
|
||||
using ReserveManagementSystemLib.Models;
|
||||
|
||||
namespace ReserveManagementSystemLib.Repositories
|
||||
{
|
||||
public interface IImportRepository
|
||||
{
|
||||
IQueryable<Import> GetAll();
|
||||
|
||||
Task<Import> FindByIdAsync(int id);
|
||||
|
||||
Task<Import> AddImportAsync(Import import);
|
||||
|
||||
Task<Import> UpdateImportAsync(Import import);
|
||||
|
||||
IQueryable<Import> GetLastLoanDnaImportByType(ImportType importType);
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
using ReserveManagementSystemLib.Models;
|
||||
|
||||
namespace ReserveManagementSystemLib.Repositories
|
||||
{
|
||||
public interface ILoanRepository
|
||||
{
|
||||
IQueryable<Loan> GetAll();
|
||||
|
||||
IQueryable<Loan> GetAllWithoutDealer();
|
||||
|
||||
Task<Loan> FindByIdAsync(int id);
|
||||
|
||||
Loan Add(Loan loan);
|
||||
|
||||
Task UpdateAsync(IEnumerable<Loan> loans);
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
using ReserveManagementSystemLib.Models;
|
||||
|
||||
namespace ReserveManagementSystemLib.Repositories
|
||||
{
|
||||
public interface ILoanTypeRepository
|
||||
{
|
||||
Task<List<LoanType>> GetLoanTypesAsync();
|
||||
|
||||
Task<LoanType> GetLoanTypeAsync(string loanTypeId);
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
using ReserveManagementSystemLib.Models;
|
||||
|
||||
namespace ReserveManagementSystemLib.Repositories
|
||||
{
|
||||
public interface IMinorAccountTypeRepository
|
||||
{
|
||||
MinorAccountType GetMinorAccountType(string accountTypeId);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
using ReserveManagementSystemLib.Models;
|
||||
|
||||
namespace ReserveManagementSystemLib.Repositories
|
||||
{
|
||||
public interface IVehicleRepository
|
||||
{
|
||||
Task<Vehicle> FindByLoanIdAsync(int? loanId);
|
||||
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
using ReserveManagementSystemLib.Enums;
|
||||
using ReserveManagementSystemLib.Models;
|
||||
using ReserveManagementSystemLib.Persistence;
|
||||
|
||||
namespace ReserveManagementSystemLib.Repositories
|
||||
{
|
||||
public class ImportRepository: BaseRepository, IImportRepository
|
||||
{
|
||||
public ImportRepository(AppDbContext context) : base(context) { }
|
||||
|
||||
public IQueryable<Import> GetAll()
|
||||
{
|
||||
return _context.Imports;
|
||||
}
|
||||
|
||||
public async Task<Import> FindByIdAsync(int id)
|
||||
{
|
||||
return await _context.Imports.FirstOrDefaultAsync(l => l.ImportId == id);
|
||||
}
|
||||
|
||||
public async Task<Import> AddImportAsync(Import import)
|
||||
{
|
||||
try
|
||||
{
|
||||
var newImport = await _context.Imports.AddAsync(import);
|
||||
await _context.SaveChangesAsync();
|
||||
return newImport.Entity;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure to add import");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<Import> UpdateImportAsync(Import import)
|
||||
{
|
||||
var updatedImport = _context.Imports.Update(import);
|
||||
await _context.SaveChangesAsync();
|
||||
return updatedImport.Entity;
|
||||
}
|
||||
|
||||
public IQueryable<Import> GetLastLoanDnaImportByType(ImportType importType)
|
||||
{
|
||||
var result = _context.Imports.Where(i => i.ImportType == importType.ToString() && i.Success == true && i.FileName == null).OrderByDescending(i => i.StartDate);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
using ReserveManagementSystemLib.Models;
|
||||
using ReserveManagementSystemLib.Persistence;
|
||||
|
||||
namespace ReserveManagementSystemLib.Repositories
|
||||
{
|
||||
public class LoanRepository : BaseRepository, ILoanRepository
|
||||
{
|
||||
public LoanRepository(AppDbContext context) : base(context) { }
|
||||
|
||||
public IQueryable<Loan> GetAll()
|
||||
{
|
||||
return _context.Loans.Include(d => d.Dealer).Include(lt => lt.LoanType).Include("Vehicle");
|
||||
}
|
||||
|
||||
public IQueryable<Loan> GetAllWithoutDealer()
|
||||
{
|
||||
return _context.Loans.Include(lt => lt.LoanType).Include("Vehicle");
|
||||
}
|
||||
|
||||
public async Task<Loan> FindByIdAsync(int id)
|
||||
{
|
||||
return await _context.Loans.Where(l => l.LoanId == id).Include(d => d.Dealer).Include(lt => lt.LoanType).Include("Vehicle").FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
public Loan Add(Loan loan)
|
||||
{
|
||||
var result =_context.Loans.Add(loan);
|
||||
_context.SaveChanges();
|
||||
|
||||
return result.Entity;
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(IEnumerable<Loan> loans)
|
||||
{
|
||||
_context.Loans.UpdateRange(loans);
|
||||
|
||||
await _context.SaveChangesAsync(); //can use this for update and add
|
||||
}
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
using ReserveManagementSystemLib.Models;
|
||||
using ReserveManagementSystemLib.Persistence;
|
||||
|
||||
namespace ReserveManagementSystemLib.Repositories
|
||||
{
|
||||
public class LoanTypeRepository: BaseRepository, ILoanTypeRepository
|
||||
{
|
||||
public LoanTypeRepository(AppDbContext context) : base(context) { }
|
||||
|
||||
public async Task<List<LoanType>> GetLoanTypesAsync()
|
||||
{
|
||||
return await _context.LoanTypes.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<LoanType> GetLoanTypeAsync(string loanTypeId)
|
||||
{
|
||||
return await _context.LoanTypes.FirstOrDefaultAsync(x => x.LoanTypeId == loanTypeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
using ReserveManagementSystemLib.Models;
|
||||
using ReserveManagementSystemLib.Persistence;
|
||||
|
||||
namespace ReserveManagementSystemLib.Repositories
|
||||
{
|
||||
public class MinorAccountTypeRepository : BaseRepository, IMinorAccountTypeRepository
|
||||
{
|
||||
public MinorAccountTypeRepository(AppDbContext context) : base(context) { }
|
||||
|
||||
/// <summary>
|
||||
/// Try to get this to work asynchronously like Loan Types will have to add a get all and then call get by id async
|
||||
/// </summary>
|
||||
/// <param name="accountTypeId"></param>
|
||||
/// <returns></returns>
|
||||
public MinorAccountType GetMinorAccountType(string accountTypeId)
|
||||
{
|
||||
return _context.MinorAccountTypes.FirstOrDefault(x => x.AccountType == accountTypeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
using ReserveManagementSystemLib.Models;
|
||||
using ReserveManagementSystemLib.Persistence;
|
||||
|
||||
namespace ReserveManagementSystemLib.Repositories
|
||||
{
|
||||
public class VehicleRepository : BaseRepository, IVehicleRepository
|
||||
{
|
||||
public VehicleRepository(AppDbContext context) : base(context) { }
|
||||
|
||||
public async Task<Vehicle> FindByLoanIdAsync(int? loanId)
|
||||
{
|
||||
return await _context.Vehicles.FirstOrDefaultAsync(v => v.LoanId == loanId);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Version>2.2.1</Version>
|
||||
<Description>
|
||||
1.1.0 Updated Loan Model, Add History Model
|
||||
1.1.1 Added Loan Filter
|
||||
1.1.2 Updated Loan and Import Models
|
||||
1.1.3 Updated Loan Audit Table/Model Add Repo
|
||||
1.1.4 More updates to Audit History table/model
|
||||
1.1.5 Update to LoanFilter model
|
||||
1.1.6 Pagination model
|
||||
1.1.7 Changes to Loan, Import, and AuditHistory models
|
||||
1.1.8 Change to LoanFilter model and Get Filtered Loans return type.
|
||||
1.1.9 Added Dealer
|
||||
1.1.10 Update to LoanFilter model and Paging model.
|
||||
1.1.11 Update to Loan model for Vehicle.
|
||||
1.1.12 Update to Vehicle model.
|
||||
1.1.13 Update to Loan Model
|
||||
1.2.0 Updated models to add LoanNumber
|
||||
1.2.1 Updated model for Filter and Paging
|
||||
1.2.2 Updated Filter to add LoanDateStart and LoanDateEnd, took out Names
|
||||
1.2.3 Added MemberNameText to LoanFilter
|
||||
1.2.4 Added LoanValidator to Model.
|
||||
1.2.5 Added Validation Results to Model.
|
||||
1.2.6 Changes to Loan and Dealer Model.
|
||||
1.2.7 Changes to Loan and Dealer Model for all caps. Validation changes.
|
||||
1.2.8 Changes to Loan Model
|
||||
1.2.9 Changes to Loan and Dealer Model
|
||||
1.2.10 Adding ApplicationId to LoanFilter
|
||||
1.2.11 Changes to Dealer and Loan Model
|
||||
1.2.12 Changes to Loan and Import models
|
||||
1.2.13 Changed Term on Loan to int
|
||||
2.0.0 Add client name to CoreApiConfiguration, fix typo in PostMonetaryTransactions
|
||||
2.1.0 Add ApiTimeOut setting for HttpClient
|
||||
2.2.0 Updates Core Api model
|
||||
2.2.1 Added queue for Active Imports
|
||||
</Description>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Blazored.FluentValidation" Version="1.4.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.18" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.18" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
|
||||
<PackageReference Include="Serilog" Version="2.10.0" />
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,9 @@
|
||||
global using Microsoft.EntityFrameworkCore;
|
||||
global using Serilog;
|
||||
global using System;
|
||||
global using System.Collections.Generic;
|
||||
global using System.ComponentModel.DataAnnotations;
|
||||
global using System.Linq;
|
||||
global using System.Threading.Tasks;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user