add not-found exception to handle on endpoint
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using MediatR;
|
using DigitalData.Core.Exceptions;
|
||||||
|
using MediatR;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using System.DirectoryServices;
|
using System.DirectoryServices;
|
||||||
|
|
||||||
@@ -39,8 +40,9 @@ public class DirectorySearchQueryHandler(IOptions<ActiveDirectoryOptions> option
|
|||||||
if (request.properties.Length > 0)
|
if (request.properties.Length > 0)
|
||||||
searcher.PropertiesToLoad.Clear();
|
searcher.PropertiesToLoad.Clear();
|
||||||
|
|
||||||
searcher.PropertiesToLoad.AddRange([.. request.properties.Where(p => p is not null)]);
|
searcher.PropertiesToLoad.AddRange(request.properties.Where(p => p is not null).ToArray());
|
||||||
return searcher.FindAll().Cast<SearchResult>().Select(r => r.Properties);
|
var res = searcher.FindAll().Cast<SearchResult>().Select(r => r.Properties);
|
||||||
|
return res.Any() ? res : throw new NotFoundException();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user