using System; using System.Collections.Generic; using System.Linq; using LCU.API.Collections.RepoApi.Domain.Processing; using LCU.Shared.Collections.RepoApiLib.Models; namespace LCU.API.Collections.RepoApi.Domain.AlertChecker { public class NoticeOfSurplusDeficiencyNotSentChecker : IAlertChecker { private const int OwnershipTypeImportant = 6; private const int DaysBeforeConsideredNotSent = 2; public List CheckForAlert(RepoAccountProcessingSlip slip) { var updatedRepoAccount = slip.UpdatedRepoAccount; if (updatedRepoAccount.RefundStatus?.RefundsReceivedDate == null || updatedRepoAccount.DateClosed != null) { return null; } var letterSentBy = DateTime.Now.AddDays(-DaysBeforeConsideredNotSent).Date; if (updatedRepoAccount.RefundStatus.RefundsReceivedDate < letterSentBy && updatedRepoAccount.Bankruptcy == null) { return new List { new EventAlert() { RepoId = updatedRepoAccount.RepoId, AccountNo = updatedRepoAccount.AccountNo, Message = "Notice of Surplus Deficiency Letter Not Sent", CreatedBy = "Batch", DateAdded = DateTime.Now, EmailRecipient = "RepoManagerAdmin@landmarkcu.com", EmailBody = CreateEmailBody(updatedRepoAccount) } }; } return null; } private string CreateEmailBody(RepoAccount repoAccount) { var message = "Notice of Surplus Deficiency Not Sent.

"; var member = repoAccount.Borrowers?.First(b => b.OwnershipType == OwnershipTypeImportant); var memberName = "Member Name: " + member?.IndividualName + "
"; var accountNo = "Account No: " + repoAccount.AccountNo + "
"; return string.Concat(message, memberName, accountNo); } } }