Skip to content
Snippets Groups Projects
Commit 682d881b authored by Petar Hristov's avatar Petar Hristov :speech_balloon:
Browse files

Fix: Index out of range

parent 40a72da4
No related branches found
No related tags found
1 merge request!13Fix: Index out of range
......@@ -287,12 +287,16 @@ public abstract class Reporting<O> where O : class
"
};
using var results = RdfStoreConnector.QueryEndpoint.QueryWithResultSet(_queryString.ToString());
if (!results.IsEmpty)
{
var inst = results.Select(x => x.Value("inst").ToString()).ToList()[0]; // Get the value for ?inst
if (!string.IsNullOrWhiteSpace(inst))
{
Console.WriteLine($" Organization {organization} found to match {inst}");
organization = inst;
return inst;
}
}
Console.WriteLine($" Could not find match for {organization}");
return organization;
}
}
\ No newline at end of file
using AngleSharp.Dom;
using Coscine.Database.DataModel;
using Coscine.Database.DataModel;
using Coscine.Database.Models;
using Coscine.Database.ReturnObjects;
using Coscine.ResourceTypes;
......
......@@ -5,5 +5,5 @@
/// </summary>
public class ReturnObject
{
public List<MaintenanceBannerObject> Banners { get; set; } = new();
public List<MaintenanceBannerObject>? Banners { get; set; } = new();
}
\ No newline at end of file
......@@ -44,7 +44,7 @@ public class SystemReporting : Reporting<SystemReportingOptions>
};
}
private async Task<List<MaintenanceBannerObject>> GetMaintenanceBannersAsync()
private async Task<List<MaintenanceBannerObject>?> GetMaintenanceBannersAsync()
{
var httpClient = new HttpClient();
var requestMessage = new HttpRequestMessage()
......@@ -60,6 +60,10 @@ public class SystemReporting : Reporting<SystemReportingOptions>
var result = await httpClient.SendAsync(requestMessage);
var responseBody = JsonConvert.DeserializeObject<List<MaintenanceBannerObject>>(result.Content.ReadAsStringAsync().Result);
if (responseBody is null)
{
return null;
}
return responseBody.OrderBy(e => e.StartAt).ToList();
}
}
......
......@@ -188,8 +188,11 @@ public class UserReporting : Reporting<UserReportingOptions>
{
Console.WriteLine($" No {searchedEntityType} found for user with ID \"{id}\" and login provider {orcidLoginProvider.DisplayName}");
}
else
{
result.Add(orgOrcid);
}
}
return result.DistinctBy(e => e.RorUrl).ToList();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment