using System; using System.Collections.Generic; using System.Linq; using LCU.API.Collections.RepoApi.Domain.Extensions; using LCU.API.Collections.RepoApi.Domain.Processing; using LCU.API.Collections.RepoApi.Extensions; using EventAlert = LCU.Shared.Collections.RepoApiLib.Models.EventAlert; namespace LCU.API.Collections.RepoApi.Domain.AlertChecker { public class RepoNotSoldChecker : IAlertChecker { private readonly int _dayCount; private readonly int _repeatDayCount; private const string RepoStatus = "REPO"; private const string DestinationEmail = "RepoManagerAdmin@landmarkcu.com"; public RepoNotSoldChecker(int dayCount = 30, int repeatDayCount = 0) { _dayCount = dayCount; _repeatDayCount = repeatDayCount; } public List CheckForAlert(RepoAccountProcessingSlip slip) { var status = slip.UpdatedRepoAccount.Status.ToUpper().Trim(); var days = slip.UpdatedRepoAccount.GetDaysInStatus(status); if (status == RepoStatus && days > 0) { if ((days == _dayCount) || days >= _dayCount && ((days - _dayCount) % _repeatDayCount == 0)) { var member = slip.UpdatedRepoAccount.Borrowers?.First(b => b.OwnershipType == 6); return new List { new EventAlert() { RepoId = slip.UpdatedRepoAccount.RepoId, AccountNo = slip.UpdatedRepoAccount.AccountNo, Message = "Repo Not Sold", CreatedBy = "Batch", DateAdded = DateTime.Now, EmailRecipient = DestinationEmail, EmailBody = string.Format("{0} {1} Account status REPO, Not Sold for extended time.", slip.UpdatedRepoAccount.AccountNo, member?.IndividualName) } }; } } return null; } } }