50 lines
1.7 KiB
C#
50 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
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 TimeInStatusChecker : IAlertChecker
|
|
{
|
|
private readonly string _checkStatus;
|
|
private readonly int _dayCount;
|
|
private readonly int _repeatDayCount;
|
|
|
|
public TimeInStatusChecker(string checkStatus, int dayCount = 30, int repeatDayCount = 0)
|
|
{
|
|
_checkStatus = checkStatus;
|
|
_dayCount = dayCount;
|
|
_repeatDayCount = repeatDayCount;
|
|
}
|
|
|
|
public List<EventAlert> CheckForAlert(RepoAccountProcessingSlip slip)
|
|
{
|
|
var status = slip.UpdatedRepoAccount.Status.ToUpper().Trim();
|
|
var days = slip.UpdatedRepoAccount.GetDaysInStatus(status);
|
|
if (days <= 0 || status != _checkStatus)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
if ((days == _dayCount) || days >= _dayCount && ((days - _dayCount) % _repeatDayCount == 0))
|
|
{
|
|
return new List<EventAlert>
|
|
{
|
|
new EventAlert()
|
|
{
|
|
RepoId = slip.UpdatedRepoAccount.RepoId,
|
|
AccountNo = slip.UpdatedRepoAccount.AccountNo,
|
|
Message = days + " days in " + _checkStatus,
|
|
CreatedBy = "Batch",
|
|
DateAdded = DateTime.Now
|
|
}
|
|
};
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
} |