Files
monorepo/LCU.API.Collections.RepoApi-old/LCU.API.Collections.RepoApi/Domain/AlertChecker/StatusChangeChecker.cs
T
2026-04-20 14:47:24 -05:00

54 lines
1.9 KiB
C#

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 StatusChangeChecker : IAlertChecker
{
private readonly string _watchStatus;
private readonly IEnumerable<string> _fromStatusList;
private const string NoStatus = "";
public StatusChangeChecker(string watchStatus, IEnumerable<string> fromStatusList = null)
{
_watchStatus = watchStatus.Trim().ToUpper();
_fromStatusList = fromStatusList;
}
public List<EventAlert> CheckForAlert(RepoAccountProcessingSlip slip)
{
var originalStatus = slip.ExistingRepoAccount?.Status.ToUpper().Trim();
var updatedStatus = slip.UpdatedRepoAccount.Status.ToUpper().Trim();
// new account.
if (originalStatus == null)
{
originalStatus = NoStatus;
}
if (updatedStatus == _watchStatus
&& originalStatus != _watchStatus
&& (_fromStatusList == null || _fromStatusList.Contains(originalStatus)))
{
return new List<EventAlert>
{
new EventAlert()
{
RepoId = slip.UpdatedRepoAccount.RepoId,
AccountNo = slip.UpdatedRepoAccount.AccountNo,
Message = "Status Changed to " + _watchStatus,
SubMessage =
$"Previously {originalStatus}. I confirm that I have updated the Status to {updatedStatus} in RDN.",
CreatedBy = "Batch",
DateAdded = DateTime.Now
}
};
}
return null;
}
}
}