This commit is contained in:
Zeeshaun
2026-04-07 14:21:04 -05:00
parent e37826fe30
commit 75ea216a17
264 changed files with 15920 additions and 0 deletions
@@ -0,0 +1,32 @@
using System.Collections.Generic;
namespace LCU.Library.Internal.LoanRateModels.Constants;
public static class RateRequestVariablesConsts
{
public static readonly List<string> RateRequestVariablesConstValues = new()
{
//RateRequest
RateRequestQualityFactor,
RateRequestTerm,
RateRequestLoanToValue,
RateRequestYear,
RateRequestRateType,
RateRequestApplicationDate,
RateRequestTotalCollateralValue,
//CalculationRequest
RateCalculationRequestCurrentRate
};
//RateRequest
public const string RateRequestQualityFactor = "RateRequest.QualityFactor";
public const string RateRequestTerm = "RateRequest.Term";
public const string RateRequestLoanToValue = "RateRequest.LoanToValue";
public const string RateRequestYear = "RateRequest.Year";
public const string RateRequestRateType = "RateRequest.RateType";
public const string RateRequestApplicationDate = "RateRequest.ApplicationDate";
public const string RateRequestTotalCollateralValue = "RateRequest.TotalCollateralValue";
//CalculationRequest
public const string RateCalculationRequestCurrentRate = "RateCalculationRequest.CurrentRate";
}
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using LCU.Library.Internal.LoanRateModels.Enums;
namespace LCU.Library.Internal.LoanRateModels.Entities.LoadTestingEntities;
public class LoadTestRunInfo
{
public int LoadTestRunInfoId { get; set; }
public DateTime StartTimeStamp { get; set; }
public DateTime? EndTimeStamp { get; set; } = null;
public RateTypes RateType { get; set; }
public int RateProcessingInfosCount { get; set; }
public int RateProcessingInfosCompleteCount { get; set; } = 0;
[ForeignKey("LoadTestRunInfoId")]
public ICollection<RateProcessingInfo> RateProcessingInfos { get; set; }
}
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using LCU.Library.Internal.LCUFilterModels.Pagination;
using LCU.Library.Internal.LoanRateModels.Enums;
namespace LCU.Library.Internal.LoanRateModels.Entities.LoadTestingEntities;
public class LoadTestRunInfoFilter : Filter
{
public LoadTestRunInfoFilter()
{
SortableFields =
new() {
new SortableField
{
Field = nameof(LoadTestRunInfo.RateType),
DisplayValue = "Rate Type",
Active = false
},
new SortableField
{
Field = nameof(LoadTestRunInfo.StartTimeStamp),
DisplayValue = "Start Time",
IsDescending = true,
Active = true
},
new SortableField
{
Field = nameof(LoadTestRunInfo.EndTimeStamp),
DisplayValue = "End Time",
Active = false
},
};
}
public bool InProgress { get; set; }
public List<RateTypes> RateTypes { get; set; } = new();
public DateTime? StartTimeStamp { get; set; }
public DateTime? EndTimeStamp { get; set; }
}
@@ -0,0 +1,15 @@
using LCU.Library.Internal.LoanRateModels.Enums.LoadTestingEnums;
namespace LCU.Library.Internal.LoanRateModels.Entities.LoadTestingEntities;
public class RateProcessingInfo
{
public int RateProcessingInfoId { get; set; }
public int LoadTestRunInfoId { get; set; }
public string Payload { get; set; }
public decimal Rate { get; set; }
public string Column { get; set; }
public string Row { get; set; }
public RateProcessingStatusTypes RateProcessingStatusType { get; set; }
public RateProcessingResultTypes RateProcessingResultType { get; set; }
public string ProcessingMessage { get; set; }
}
@@ -0,0 +1,6 @@
using LCU.Library.Internal.LCUFilterModels.Pagination;
namespace LCU.Library.Internal.LoanRateModels.Entities.LoadTestingEntities;
public class RateProcessingInfoFilter : Filter
{
}
@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace LCU.Library.Internal.LoanRateModels.Entities;
public class Rate
{
public int RateId { get; set; }
public int? RateUploadInfoId { get; set; }
public int? ClosingRateUploadInfoId { get; set; }
public string Column { get; set; }
public string Row { get; set; }
public int RateSheetId { get; set; }
public decimal Value { get; set; }
[Required]
[Range(typeof(DateTime), "1/2/0001", "12/30/9999", ErrorMessage = "Value for {0} must be between {1} and {2}")]
public DateTime RateStartDate { get; set; }
public DateTime? RateEndDate { get; set; }
[ForeignKey("RateId")]
public ICollection<RateEvaluation> RateEvaluations { get; set; }
public Rate DeepCopyNewRate()
{
Rate newRate = (Rate)this.MemberwiseClone();
newRate.RateId = 0;
newRate.RateEvaluations = new List<RateEvaluation>();
foreach (var rateRule in RateEvaluations)
{
var newRateRule = (RateEvaluation)rateRule.ShallowCopyNewRate();
newRate.RateEvaluations.Add(newRateRule);
}
return newRate;
}
}
@@ -0,0 +1,21 @@
using System.ComponentModel.DataAnnotations.Schema;
using LCU.Library.Internal.LcuEvaluationModels.Entities;
namespace LCU.Library.Internal.LoanRateModels.Entities;
public class RateEvaluation
{
public int RateEvaluationId { get; set; }
public int RateId { get; set; }
public int EvaluationDetailId { get; set; }
[ForeignKey("EvaluationDetailId")]
public EvaluationDetail EvaluationDetail { get; set; }
public RateEvaluation ShallowCopyNewRate()
{
var newRateRule = (RateEvaluation)MemberwiseClone();
newRateRule.RateEvaluationId = 0;
newRateRule.RateId = 0;
return newRateRule;
}
}
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using LCU.Library.Internal.LoanRateModels.Enums;
using LCU.Library.Internal.TypeExtensions.EnumExtensions;
namespace LCU.Library.Internal.LoanRateModels.Entities;
public class RateSheet
{
[Key]
public int RateSheetId { get; set; }
[Required]
public RateTypes RateType { get; set; }
[Required]
public string CreatedBy { get; set; } = "System";
public DateTime TimeCreated { get; set; } = DateTime.Now;
public string SheetName => RateType.GetNameFromValue();
[ForeignKey("RateSheetId")]
public ICollection<Rate> Rates { get; set; }
[ForeignKey("RateSheetId")]
public ICollection<RateSheetCell> RateSheetCells { get; set; }
}
@@ -0,0 +1,20 @@
using System.ComponentModel.DataAnnotations;
using LCU.Library.Internal.LoanRateModels.Enums;
namespace LCU.Library.Internal.LoanRateModels.Entities;
public class RateSheetCell
{
[Key]
public int RateSheetCellId { get; set; }
[Required]
public int RateSheetId { get; set; }
[Required]
public string Column { get; set; }
public int ColumnSpan { get; set; } = 1;
[Required]
public string Row { get; set; }
public int RowSpan { get; set; } = 1;
public string Value { get; set; }
public RateSheetCellTypes RateSheetCellType { get; set; }
}
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace LCU.Library.Internal.LoanRateModels.Entities;
public class RateUploadInfo
{
[Key]
public int RateUploadInfoId { get; set; }
public int Version { get; set; }
public string Filename { get; set; }
public DateTime EffectiveDate { get; set; }
public DateTime TimeCreated { get; set; }
public string CreatedBy { get; set; }
public int RateCount { get; set; }
[ForeignKey("RateUploadInfoId")]
public ICollection<Rate> Rates { get; set; }
[ForeignKey("ClosingRateUploadInfoId")]
public ICollection<Rate>? ClosedRates { get; set; }
}
@@ -0,0 +1,33 @@
using System;
using LCU.Library.Internal.LCUFilterModels.Pagination;
namespace LCU.Library.Internal.LoanRateModels.Entities;
public class RateUploadInfoFilter : Filter
{
public RateUploadInfoFilter()
{
SortableFields =
new() {
new SortableField
{
Position = 0,
Field = nameof(RateUploadInfo.EffectiveDate),
DisplayValue = "Effective Date",
IsDescending = true,
Active = true
},
new SortableField
{
Position = 1,
Field = nameof(RateUploadInfo.Version),
DisplayValue = "Version",
IsDescending = true,
Active = true
}
};
}
public int? Version { get; set; }
public DateTime? EffectiveDate { get; set; }
public string? CreatedBy { get; set; }
}
@@ -0,0 +1,8 @@
namespace LCU.Library.Internal.LoanRateModels.Enums.LoadTestingEnums;
public enum RateProcessingResultTypes
{
NA = 0,
RateFound = 1,
RateFailure = 2
}
@@ -0,0 +1,8 @@
namespace LCU.Library.Internal.LoanRateModels.Enums.LoadTestingEnums;
public enum RateProcessingStatusTypes
{
Processing = 0,
Complete = 1,
CriticalFailure = 2
}
@@ -0,0 +1,7 @@
namespace LCU.Library.Internal.LoanRateModels.Enums;
public enum RateSheetCellTypes
{
TopHeader,
LeftHeader
}
@@ -0,0 +1,34 @@
using System.ComponentModel.DataAnnotations;
namespace LCU.Library.Internal.LoanRateModels.Enums;
public enum RateTypes
{
[Display(Name = "Direct Boat Rates")]
DirectBoat = 0,
[Display(Name = "Direct Powersport Rates")]
DirectPowerSport = 1,
[Display(Name = "Direct RV Rates")]
DirectRv = 2,
[Display(Name = "Direct Signature Loan Rates")]
DirectSignatureLoan = 3,
[Display(Name = "Direct Motorcycle Rates")]
DirectMotorcycle = 4,
[Display(Name = "Direct Auto Rates")]
DirectAuto = 5,
[Display(Name = "WI Indirect Boat Buy Rates")]
WiIndirectBoatBuy = 6,
[Display(Name = "IL Indirect Boat Buy Rates")]
IlIndirectBoatBuy = 7,
[Display(Name = "WI Indirect Motorcycle Buy Rate")]
WiIndirectMotorcycleBuy = 8,
[Display(Name = "WI Indirect Powersport Buy Rate")]
WiIndirectPowerSportBuy = 9,
[Display(Name = "IL Indirect Motorcycle Buy Rate")]
IlIndirectMotorcycleBuy = 10,
[Display(Name = "IL Indirect Powersport Buy Rate")]
IlIndirectPowerSportBuy = 11,
[Display(Name = "WI Indirect Auto Buy Rates")]
WiIndirectAutoBuy = 12,
[Display(Name = "IL Indirect Auto Buy Rates")]
IlIndirectAutoBuy = 13
}
@@ -0,0 +1,83 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<GeneratePackageOnBuild Condition="'$(Configuration)'!='Test'">True</GeneratePackageOnBuild>
<LangVersion>latest</LangVersion>
<Version>2.4.0</Version>
<Description>
1.0.0 - Initial Creation of Models Library.
1.1.0 - Refactor to use Evaluation, Added RateRequestVariablesConsts, and added RateCalcuationRequest
1.2.0 - Fix RateRequestVariablesConst's namespace and added static to class/list
1.2.2 - Update LoanRateEvaluationModels library
1.2.3 - Added to VehicleRateRequest, created VehiclePurposeTypes, created VehicleRateTypes, and added to RateRequestVariablesConsts.
1.2.4 - Fix NonCashOutRefis typo.
1.3.0 - Adding RateRequest which has the RateType property and also extends EvaluationRequest. VehicleRateRequest now extends RateRequest.
1.4.0 - Adding VehicleRateRequest VehicleTypes and removed the LTV Calc as it will be entered.
1.4.1 - Rename new enum VehicleTypes to VehicleSubTypes and add default of none.
1.4.2 - Update LoanRateEvaluationModels library
1.5.0 - Adding HomeEquityRateRequest, HomeLoanTypes, and LienPositionTypes
1.6.0 - Updating LoanRateEvaluationModels for CurrentYear Parameter
2.0.0 - Refactor RateRequest and RateTypes, add RateResponse
2.1.0 - Add InitiateRatesEvaluationsResponse model
2.2.0 - Add RateUploadExcelDataRequest and RateUploadRequest models
2.2.1 - Fix RateRequestVariablesConsts RateRequest.Year
2.3.0 - Adding LoadTesting Entities and Request models.
2.3.1 - Update LoanRateEvaluationModels library
2.3.2 - Ratetype change DirectMrex to be DirectSignatureLoan.
2.3.3 - Add LoadTestRunInfoFilter
2.3.4 - Add RateProcessingInfoFilter
2.3.5 - Add RateUploadInfo
2.3.6 - Change Rate.RateUploadInfoId to nullable
2.3.7 - Add RateUploadInfoFilter
2.3.8 - Update RateUploadInfo.Filepath to RateUploadInfo.Filename
2.3.9 - Upgrade to .Net 8
2.3.10 - Add ClosedRates to RateUploadInfo
2.3.11 - Add RateSheetCellTypes enum
2.3.12 - Add RateUploadInfoRequest
2.4.0 - Add Validation models
</Description>
<PackageReleaseNotes>
1.0.0 - Initial Creation of Models Library.
1.1.0 - Refactor to use Evaluation, Added RateRequestVariablesConsts, and added RateCalcuationRequest
1.2.0 - Fix RateRequestVariablesConst's namespace and added static to class/list
1.2.1 - Update LoanRateEvaluationModels library
1.2.2 - Update LoanRateEvaluationModels library
1.2.3 - Added to VehicleRateRequest, created VehiclePurposeTypes, created VehicleRateTypes, and added to RateRequestVariablesConsts.
1.2.4 - Fix NonCashOutRefis typo.
1.3.0 - Adding RateRequest which has the RateType property and also extends EvaluationRequest. VehicleRateRequest now extends RateRequest.
1.4.0 - Adding VehicleRateRequest VehicleTypes and removed the LTV Calc as it will be entered.
1.4.1 - Rename new enum VehicleTypes to VehicleSubTypes and add default of none.
1.4.2 - Update LoanRateEvaluationModels library
1.5.0 - Adding HomeEquityRateRequest, HomeLoanTypes, and LienPositionTypes
1.6.0 - Updating LoanRateEvaluationModels for CurrentYear Parameter
2.0.0 - Refactor RateRequest and RateTypes, add RateResponse
2.1.0 - Add InitiateRatesEvaluationsResponse model
2.2.0 - Add RateUploadExcelDataRequest and RateUploadRequest models
2.2.1 - Fix RateRequestVariablesConsts RateRequest.Year
2.3.0 - Adding LoadTesting Entities and Request models.
2.3.1 - Update LoanRateEvaluationModels library
2.3.2 - Ratetype change DirectMrex to be DirectSignatureLoan.
2.3.3 - Add LoadTestRunInfoFilter
2.3.4 - Add RateProcessingInfoFilter
2.3.5 - Add RateUploadInfo
2.3.6 - Change Rate.RateUploadInfoId to nullable
2.3.7 - Add RateUploadInfoFilter
2.3.8 - Update RateUploadInfo.Filepath to RateUploadInfo.Filename
2.3.9 - Upgrade to .Net 8
2.3.10 - Add ClosedRates to RateUploadInfo
2.3.11 - Add RateSheetCellTypes enum
2.3.12 - Add RateUploadInfoRequest
2.4.0 - Add Validation models
</PackageReleaseNotes>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="LCU.Api.Internal.FileOperationsLib" Version="3.30.6" />
<PackageReference Include="LCU.Library.Internal.LcuEvaluationModels" Version="2.0.1" />
<PackageReference Include="LCU.Library.Internal.LCUFilterModels" Version="1.0.0" />
<PackageReference Include="LCU.Library.Internal.TypeExtensions" Version="1.2.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup>
</Project>
@@ -0,0 +1,13 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace LCU.Library.Internal.LoanRateModels.Requests;
public class InitiateRatesEvaluationsRequest
{
[Required]
public string SheetName { get; set; }
[Required]
public int EvaluationDetailId { get; set; }
public List<string> RowsOrColumns { get; set; }
public bool IsRowsRule { get; set; }
}
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using LCU.Library.Internal.LoanRateModels.Enums;
namespace LCU.Library.Internal.LoanRateModels.Requests.LoadTestRequest;
public class LoadTestInitiateRequest
{
[Required]
public RateTypes? RateType { get; set; }
[PropertyListValidation]
public Dictionary<string, List<string>> PropertyList { get; set; }
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
public class PropertyListValidation : ValidationAttribute
{
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
if (!(value is Dictionary<string, List<string>> dictionary))
return new ValidationResult("Object is not of proper type");
if (dictionary.ContainsKey(nameof(RateRequest.RateType)))
{
return new ValidationResult($"{nameof(RateRequest.RateType)} cannot be declared in the PropertyList.");
}
return ValidationResult.Success;
}
}
@@ -0,0 +1,7 @@
using LCU.Library.Internal.LoanRateModels.Entities.LoadTestingEntities;
namespace LCU.Library.Internal.LoanRateModels.Requests.LoadTestRequest;
public class LoadTestProcessRateRequest
{
public RateProcessingInfo RateProcessingInfo { get; set; }
}
@@ -0,0 +1,7 @@
using LCU.Library.Internal.LoanRateModels.Entities.LoadTestingEntities;
namespace LCU.Library.Internal.LoanRateModels.Requests.LoadTestRequest;
public class LoadTestRateCompletionRequest
{
public RateProcessingInfo RateProcessingInfo { get; set; }
}
@@ -0,0 +1,9 @@
using System.ComponentModel;
using LCU.Library.Internal.LcuEvaluationModels.Requests;
namespace LCU.Library.Internal.LoanRateModels.Requests;
public class RateCalculationRequest : EvaluationRequest
{
[DisplayName("RateCalculationRequest.CurrentRate")]
public decimal CurrentRate { get; set; }
}
@@ -0,0 +1,29 @@
using System;
using System.ComponentModel;
using LCU.Library.Internal.LcuEvaluationModels.Requests;
using LCU.Library.Internal.LoanRateModels.Enums;
namespace LCU.Library.Internal.LoanRateModels.Requests;
public class RateRequest : EvaluationRequest
{
[DisplayName("RateRequest.QualityFactor")]
public string QualityFactor { get; set; }
[DisplayName("RateRequest.Term")]
public int Term { get; set; }
[DisplayName("RateRequest.LoanToValue")]
public decimal LoanToValue { get; set; }
[DisplayName("RateRequest.Year")]
public string Year { get; set; }
[DisplayName("RateRequest.RateType")]
public RateTypes RateType { get; set; }
[DisplayName("RateRequest.ApplicationDate")]
public DateTime ApplicationDate { get; set; }
[DisplayName("RateRequest.TotalCollateralValue")]
public decimal TotalCollateralValue { get; set; }
}
@@ -0,0 +1,12 @@
using System.Collections.Generic;
using LCU.Library.Internal.LoanRateModels.Enums;
namespace LCU.Library.Internal.LoanRateModels.Requests;
public class RateSheetCellUpload
{
public RateTypes RateType { get; set; }
public List<string> HeaderTopColumns { get; set; }
public List<int> HeaderTopRows { get; set; }
public List<string> HeaderLeftColumns { get; set; }
public List<int> HeaderLeftRows { get; set; }
}
@@ -0,0 +1,8 @@
using System.Collections.Generic;
namespace LCU.Library.Internal.LoanRateModels.Requests;
public class RateSheetCellUploadRequest
{
public string FileContent { get; set; }
public List<RateSheetCellUpload> Requests { get; set; }
}
@@ -0,0 +1,9 @@
using System;
using LCU.Library.Internal.LoanRateModels.Enums;
namespace LCU.Library.Internal.LoanRateModels.Requests;
public class RateSheetRequest
{
public RateTypes RateType { get; set; }
public DateTime EffectiveDate { get; set; }
}
@@ -0,0 +1,11 @@
using System;
using LCU.Api.Internal.FileOperationsLib.Models.ExcelModels.Requests;
namespace LCU.Library.Internal.LoanRateModels.Requests;
public class RateUploadExcelDataRequest
{
public string FileName { get; set; }
public DateTime EffectiveDate { get; set; }
public ExcelDataRequest ExcelDataRequest { get; set; }
public string CreatedBy { get; set; } = "System";
}
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using LCU.Library.Internal.LoanRateModels.Entities;
namespace LCU.Library.Internal.LoanRateModels.Requests;
public class RateUploadInfoRequest
{
public List<Rate> Rates { get; set; } = new();
public string FileName { get; set; }
public DateTime EffectiveDate { get; set; }
public string CreatedBy { get; set; } = "System";
}
@@ -0,0 +1,10 @@
using System;
namespace LCU.Library.Internal.LoanRateModels.Requests;
public class RateUploadRequest
{
public string FileContent { get; set; }
public string FileName { get; set; }
public DateTime EffectiveDate { get; set; }
public string CreatedBy { get; set; } = "System";
}
@@ -0,0 +1,31 @@
using System.Collections.Generic;
using LCU.Library.Internal.LoanRateModels.Entities;
using LCU.Library.Internal.LoanRateModels.Requests;
namespace LCU.Library.Internal.LoanRateModels.Responses;
public class InitiateRatesEvaluationsResponse
{
public bool Success { get; set; } = true;
public InitiateRatesEvaluationsRequest Request { get; set; }
public List<RateEvaluation> RateEvaluationResults { get; set; } = new();
public List<string> Messages { get; set; } = new();
}
public static class InitiateRatesEvaluationsResponseUtilities
{
public static InitiateRatesEvaluationsResponse AddSuccessMessage(this InitiateRatesEvaluationsResponse response, string message)
{
response.Success = true;
response.Messages.Add(message);
return response;
}
public static InitiateRatesEvaluationsResponse AddFailureMessage(this InitiateRatesEvaluationsResponse response, string message)
{
response.Success = false;
response.Messages.Add(message);
return response;
}
}
@@ -0,0 +1,37 @@
using System.Collections.Generic;
namespace LCU.Library.Internal.LoanRateModels.Responses;
public class RateResponse
{
public bool Success { get; set; } = true;
public decimal Rate { get; set; }
public List<string> Messages { get; set; } = new();
}
public static class RateResponseUtilities
{
private const decimal RateDefaultValue = (decimal)99.0;
public static RateResponse AddErrorMessage(this RateResponse rateResponse, string message)
{
rateResponse.Messages.Add(message);
rateResponse.Success = false;
return rateResponse;
}
public static RateResponse AddErrorMessage(this RateResponse rateResponse, IEnumerable<string> message)
{
rateResponse.Messages.AddRange(message);
return rateResponse;
}
public static RateResponse SetDefault(this RateResponse rateResponse)
{
return new RateResponse
{
Messages = rateResponse.Messages,
Rate = RateDefaultValue
};
}
}
@@ -0,0 +1,20 @@
using LCU.Library.Internal.LCUFilterModels.Pagination;
using LCU.Library.Internal.LoanRateModels.Entities;
namespace LCU.Library.Internal.LoanRateModels.Responses;
public class RateUploadInfoFilterResponse : PagedResponse<RateUploadInfo>
{
public RateUploadInfoFilterResponse() { }
public RateUploadInfoFilterResponse(RateUploadInfoFilterResult pagedResult, RateUploadInfoFilter filter)
{
TotalCount = pagedResult.TotalCount;
LatestRateUploadInfo = pagedResult.LatestRateUploadInfo;
PagedResponse = new PagedResponse<RateUploadInfo>(pagedResult, filter);
}
public int TotalCount { get; set; }
public RateUploadInfo LatestRateUploadInfo { get; set; }
public PagedResponse<RateUploadInfo> PagedResponse { get; set; }
}
@@ -0,0 +1,10 @@
using LCU.Library.Internal.LCUFilterModels.Pagination;
using LCU.Library.Internal.LoanRateModels.Entities;
namespace LCU.Library.Internal.LoanRateModels.Responses;
public class RateUploadInfoFilterResult : PagedResult<RateUploadInfo>
{
public int TotalCount { get; set; }
public RateUploadInfo LatestRateUploadInfo { get; set; }
}
@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace LCU.Library.Internal.LoanRateModels.Responses.Validation.RateSheetValidations;
public static class RateSheetValidation
{
public static RateSheetValidationItem IsWithinTrendRange(decimal oldValue, decimal newValue, List<decimal> history)
{
var validation = new RateSheetValidationItem
{
Label = "Within Trend Range",
Description = "If there is a history of change, is the current trend within the trend history's max and min values.",
RateSheetValidationType = RateSheetValidationTypes.IsWithinTrendRange
};
if (newValue == 0 || oldValue == 0)
{
validation.Pass = false;
validation.Message = $"Values cannot be zero. OldValue: {oldValue} | NewValue: {newValue}";
return validation;
}
var currentTrend = oldValue / newValue;
var trends = history.Zip(history.Skip(1), (x, y) => y / x).ToList();
var currentTrendString = Math.Round(currentTrend * 100, 2).ToString("0.##");
var minTrendString = Math.Round(trends.Min() * 100, 2).ToString("0.##");
var maxTrendString = Math.Round(trends.Max() * 100, 2).ToString("0.##");
validation.Value = currentTrendString;
validation.Formula = trends.Count == 0
? "No history found"
: $"{currentTrendString} >= {minTrendString} && {currentTrendString} <= {maxTrendString}";
validation.Criteria = trends.Count == 0
? "No history found"
: $"{minTrendString}% - {maxTrendString}%";
validation.Pass = trends.Count == 0 || currentTrend >= trends.Min() && currentTrend <= trends.Max();
return validation;
}
public static RateSheetValidationItem IsWithinRange(decimal value, decimal min, decimal max)
=> new()
{
Label = "Within Range",
Description = "Value is within the min and max values.",
Value = value.ToString("0.##"),
Formula = $"{value:0.##} >= {min:0.##} && {value:0.##} <= {max:0.##}",
Criteria = $"{min:0.##} - {max:0.##}",
Pass = value >= min && value <= max,
RateSheetValidationType = RateSheetValidationTypes.IsWithinRange
};
}
@@ -0,0 +1,5 @@
namespace LCU.Library.Internal.LoanRateModels.Responses.Validation.RateSheetValidations;
public class RateSheetValidationItem : ValidationItem
{
public RateSheetValidationTypes RateSheetValidationType { get; set; }
}
@@ -0,0 +1,8 @@
using System.Collections.Generic;
using LCU.Library.Internal.LoanRateModels.Entities;
namespace LCU.Library.Internal.LoanRateModels.Responses.Validation.RateSheetValidations;
public class RateSheetValidationResult : ValidationResult<Rate, RateSheetValidationItem>
{
public override List<RateSheetValidationItem> Validations { get; set; }
}
@@ -0,0 +1,6 @@
namespace LCU.Library.Internal.LoanRateModels.Responses.Validation.RateSheetValidations;
public enum RateSheetValidationTypes
{
IsWithinTrendRange,
IsWithinRange
}
@@ -0,0 +1,11 @@
namespace LCU.Library.Internal.LoanRateModels.Responses.Validation;
public class ValidationItem
{
public string Label { get; set; } = string.Empty;
public string Value { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public string Criteria { get; set; } = string.Empty;
public string Formula { get; set; } = string.Empty;
public string Message { get; set; } = string.Empty;
public bool Pass { get; set; }
}
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace LCU.Library.Internal.LoanRateModels.Responses.Validation;
public class ValidationResult<TEntity, TValidationItem> where TValidationItem : ValidationItem
{
public TEntity NewItem { get; set; }
public TEntity? OriginalItem { get; set; }
public virtual List<TValidationItem> Validations { get; set; }
public string Message { get; set; } = string.Empty;
public bool Pass { get; set; } = true;
public List<string> ValidationMessages => Validations.Where(x => !string.IsNullOrWhiteSpace(x.Message))
.Select(x => x.Message).ToList();
public List<TValidationItem> PassedValidations => Validations.Where(x => x.Pass).ToList();
public List<TValidationItem> FailedValidations => Validations.Where(x => !x.Pass).ToList();
public double Percentage => Math.Round(((double)PassedValidations.Count / Validations.Count) * 100, 2);
public bool CheckValidation()
{
Pass = Validations.Count == 0 || Validations.All(x => x.Pass);
return Pass;
}
}