fix: avoid null api responses
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||
<M42ExtensionId>6673a25d-33d6-4072-91d9-abed4be1a966</M42ExtensionId>
|
||||
<M42AssemblyPattern>C4ITF4SD*.*</M42AssemblyPattern>
|
||||
<M42PackageVersion>1.4.0.38</M42PackageVersion>
|
||||
<M42PackageVersion>1.4.0.39</M42PackageVersion>
|
||||
<M42BuildPackage>true</M42BuildPackage>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -98,12 +98,13 @@ namespace C4IT.F4SD
|
||||
public async Task<F4SDHelperService.DirectLink> getDirectLinkCreateTicket(string sid = "", string assetname = "")
|
||||
{
|
||||
await Task.Delay(0);
|
||||
return await _f4stHelperService.getDirectLinkCreateTicket(sid, assetname);
|
||||
return await _f4stHelperService.getDirectLinkCreateTicket(sid, assetname)
|
||||
?? new F4SDHelperService.DirectLink();
|
||||
}
|
||||
[Route("getDirectLinkF4SD"), HttpGet]
|
||||
public async Task<string> getDirectLinkF4SD(Guid EOID, string Type)
|
||||
{
|
||||
return await _f4stHelperService.getDirectLinkF4SD(EOID, Type);
|
||||
return await _f4stHelperService.getDirectLinkF4SD(EOID, Type) ?? string.Empty;
|
||||
}
|
||||
|
||||
[Route("getTicketList"), HttpGet]
|
||||
@@ -130,16 +131,16 @@ namespace C4IT.F4SD
|
||||
public async Task<cF4SDTicket> getTicketDetails(Guid objectId)
|
||||
{
|
||||
var tickets = await _f4stHelperService.getTicketDetails(new List<Guid>() { objectId });
|
||||
if (tickets.Count > 0)
|
||||
if (tickets?.Count > 0)
|
||||
return tickets[0];
|
||||
else
|
||||
return null;
|
||||
|
||||
return new cF4SDTicket { TicketObjectId = objectId };
|
||||
}
|
||||
|
||||
[Route("getTicketHistory"), HttpGet]
|
||||
public async Task<List<cTicketJournalItem>> getTicketHistory(Guid objectId)
|
||||
{
|
||||
return await _f4stHelperService.GetJournalEntries(objectId);
|
||||
return await _f4stHelperService.GetJournalEntries(objectId) ?? new List<cTicketJournalItem>();
|
||||
}
|
||||
|
||||
[Route("getTicketOverviewCounts"), HttpGet]
|
||||
@@ -158,7 +159,8 @@ namespace C4IT.F4SD
|
||||
.ToList();
|
||||
|
||||
var decodedQueues = ParseQueues(queues);
|
||||
return await _f4stHelperService.getTicketOverviewCounts(sid, scope, parsedKeys, queueoption, decodedQueues);
|
||||
return await _f4stHelperService.getTicketOverviewCounts(sid, scope, parsedKeys, queueoption, decodedQueues)
|
||||
?? new F4SDHelperService.TicketOverviewCountsResult();
|
||||
}
|
||||
|
||||
[Route("getTicketOverviewCountsByRoles"), HttpPost]
|
||||
@@ -182,7 +184,7 @@ namespace C4IT.F4SD
|
||||
parsedKeys,
|
||||
request?.QueueOption ?? 0,
|
||||
decodedQueues
|
||||
);
|
||||
) ?? new F4SDHelperService.TicketOverviewCountsByRoleResult();
|
||||
}
|
||||
|
||||
[Route("getTicketOverviewRelations"), HttpGet]
|
||||
@@ -196,7 +198,8 @@ namespace C4IT.F4SD
|
||||
)
|
||||
{
|
||||
var decodedQueues = ParseQueues(queues);
|
||||
return await _f4stHelperService.getTicketOverviewRelations(sid, scope, key, count, queueoption, decodedQueues);
|
||||
return await _f4stHelperService.getTicketOverviewRelations(sid, scope, key, count, queueoption, decodedQueues)
|
||||
?? new List<F4SDHelperService.TicketOverviewRelationDto>();
|
||||
}
|
||||
/*
|
||||
[Route("updateActivitySolution/{objectId}"), HttpPost]
|
||||
@@ -244,7 +247,7 @@ namespace C4IT.F4SD
|
||||
throw new UnauthorizedAccessException("Cannot determine the interactive Matrix42 user.");
|
||||
|
||||
var filter = AsqlHelper.BuildInCondition("ID", new Guid[] { userId });
|
||||
return await _f4stHelperService.UserPermissionsInfo(filter);
|
||||
return await _f4stHelperService.UserPermissionsInfo(filter) ?? new UserPermissionsInfo();
|
||||
}
|
||||
[HttpGet]
|
||||
[Route("getRoleMemberships")]
|
||||
@@ -267,12 +270,10 @@ namespace C4IT.F4SD
|
||||
|
||||
if (!string.IsNullOrEmpty(filter))
|
||||
{
|
||||
return await _f4stHelperService.UserPermissionsInfo(filter);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
return await _f4stHelperService.UserPermissionsInfo(filter) ?? new UserPermissionsInfo();
|
||||
}
|
||||
|
||||
return new UserPermissionsInfo();
|
||||
}
|
||||
|
||||
public class TicketOverviewCountsByRolesRequest
|
||||
@@ -414,7 +415,7 @@ namespace C4IT.F4SD
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
return null;
|
||||
return string.Empty;
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -486,7 +487,7 @@ namespace C4IT.F4SD
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
return null;
|
||||
return Enumerable.Empty<cM42LogEntry>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,7 +502,7 @@ namespace C4IT.F4SD
|
||||
[OperationType(OperationType.GetObject)]
|
||||
public cM42LogEntry GetClass(int id)
|
||||
{
|
||||
return _f4stHelperService.privGetLog2(id);
|
||||
return _f4stHelperService.privGetLog2(id) ?? new cM42LogEntry { LineNumber = id };
|
||||
}
|
||||
|
||||
private static IEnumerable<cM42LogEntry> ApplyLogFilter(IEnumerable<cM42LogEntry> entries, ODataQueryOptions<cM42LogEntry> queryOptions)
|
||||
|
||||
Reference in New Issue
Block a user