51 lines
1.7 KiB
C#
51 lines
1.7 KiB
C#
using System.Collections.Generic;
|
|
using Pipefy.Models;
|
|
|
|
namespace Pipefy.Services
|
|
{
|
|
public class BusinessLogicService : IBusinessLogicService
|
|
{
|
|
public List<ClasseEmpresas> CompareData(List<ClasseEmpresas> databaseData, List<ClasseEmpresas> jsonList, List<ClasseGestores> jsonListGestores)
|
|
{
|
|
if (jsonList == null || jsonListGestores == null)
|
|
{
|
|
return databaseData;
|
|
}
|
|
List<ClasseEmpresas> recordsMissingInJson = new List<ClasseEmpresas>();
|
|
foreach (var record in databaseData)
|
|
{
|
|
bool exists = false;
|
|
for (var j = 0; j < jsonList.Count; j++)
|
|
{
|
|
if (jsonList[j].c_digo_smart!.ToString().Replace(".0", "") == record.c_digo_smart!.ToString())
|
|
{
|
|
exists = true;
|
|
break;
|
|
}
|
|
}
|
|
if (!exists)
|
|
{
|
|
record.gestores = FindGestores(record.gestores!, jsonListGestores);
|
|
if (record.gestores != "0")
|
|
{
|
|
recordsMissingInJson.Add(record);
|
|
}
|
|
}
|
|
}
|
|
return recordsMissingInJson;
|
|
}
|
|
|
|
public string FindGestores(string sCodigo, List<ClasseGestores> jsonListGestores)
|
|
{
|
|
for (var i = 0; i < jsonListGestores.Count; i++)
|
|
{
|
|
if (sCodigo == jsonListGestores[i].gestores!.ToString())
|
|
{
|
|
return jsonListGestores[i].id!;
|
|
}
|
|
}
|
|
return "0";
|
|
}
|
|
}
|
|
}
|