string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
LookupInputs data = JsonConvert.DeserializeObject<LookupInputs>(requestBody);
if (data == null)
return new BadRequestObjectResult("There was no data provided, or the data was not formatted properly");
Dictionary<string, List<Dictionary<string, JToken>>> result = new()
{
{ "inject", new() },
{ "update", new() }
};
if (data.TargetJson.Count == 0)
{
result["inject"] = (from item in data.SourceJson select item).ToList();
}
else
{
result["inject"] = (from source in data.SourceJson
from target in data.TargetJson
where source[data.CommonIdentifier] != target[data.CommonIdentifier] && !source.DictEquals(target)
select source).ToList();
result["update"] = (from source in data.SourceJson
from target in data.TargetJson
where source[data.CommonIdentifier] == target[data.CommonIdentifier] // && !source.DictEquals(target)
select target).ToList();
}
return new OkObjectResult(results);
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
LookupInputs data = JsonConvert.DeserializeObject<LookupInputs>(requestBody);
if (data == null)
return new BadRequestObjectResult("There was no data provided, or the data was not formatted properly");
Dictionary<string, List<Dictionary<string, JToken>>> result = new()
{
{ "inject", new() },
{ "update", new() }
};
if (data.TargetJson.Count == 0)
{
result["inject"] = (from item in data.SourceJson select item).ToList();
}
else
{
result["inject"] = (from source in data.SourceJson
from target in data.TargetJson
where source[data.CommonIdentifier] != target[data.CommonIdentifier] && !source.DictEquals(target)
select source).ToList();
result["update"] = (from source in data.SourceJson
from target in data.TargetJson
where source[data.CommonIdentifier] == target[data.CommonIdentifier] // && !source.DictEquals(target)
select target).ToList();
}
return new OkObjectResult(results);