public void UpdateFromIOTest() { //arrage List <MLFSIncome> income = new List <MLFSIncome>(); MLFSIncome i = new MLFSIncome() { Id = 1, IOReference = "123456", ReportingPeriodId = 2, RelevantDate = DateTime.Now, ClientId = "234", Amount = 100, PlanNumber = "9876" }; income.Add(i); MLFSIncome i2 = new MLFSIncome() { Id = 2, IOReference = "1234567", ReportingPeriodId = 2, RelevantDate = DateTime.Now, ClientId = "345", Amount = 100, PlanNumber = "9877" }; income.Add(i2); List <MLFSClient> clients = new List <MLFSClient>(); MLFSClient c = new MLFSClient() { PrimaryID = "234", Name = "John Smith", IsActive = true, CreatedOn = DateTime.Parse("01/01/2001") }; MLFSClient c2 = new MLFSClient() { PrimaryID = "231", Name = "John Adams", IsActive = false, CreatedOn = DateTime.Parse("10/01/2001") }; clients.Add(c); clients.Add(c2); //act MLFSIncome.UpdateFromIO(income, clients); //assert Assert.AreEqual(DateTime.Parse("01/01/2001"), i.ClientOnBoardDate, "On board date not updated"); }
public async Task UpdateClientOnboardDate(MLFSReportingPeriod period) { List <MLFSIncome> incomeLines = await _db.MLFSIncome.Where(x => x.ReportingPeriodId == period.Id && x.ClientOnBoardDate == null).ToListAsync(); incomeLines = incomeLines.Where(x => x.IsNewBusiness).ToList(); if (incomeLines.Count > 0) { string[] ids = incomeLines.Select(x => x.ClientId).ToArray(); while (ids.Length != 0) { string[] idsForSubmission; string idString = ""; if (ids.Length > 100) { idsForSubmission = ids.Take(100).ToArray(); } else { idsForSubmission = ids; } foreach (string id in idsForSubmission) { if (!String.IsNullOrEmpty(id)) { idString += id + ","; } } idString = idString.TrimEnd(','); idString = "(" + idString + ")"; List <MLFSClient> clients = await _clientData.GetClients(idString); if (clients != null) { MLFSIncome.UpdateFromIO(incomeLines, clients); } ids = ids.Except(idsForSubmission).ToArray(); } } }