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 System.DirectoryServices;
|
||||
|
||||
@@ -39,8 +40,9 @@ public class DirectorySearchQueryHandler(IOptions<ActiveDirectoryOptions> option
|
||||
if (request.properties.Length > 0)
|
||||
searcher.PropertiesToLoad.Clear();
|
||||
|
||||
searcher.PropertiesToLoad.AddRange([.. request.properties.Where(p => p is not null)]);
|
||||
return searcher.FindAll().Cast<SearchResult>().Select(r => r.Properties);
|
||||
searcher.PropertiesToLoad.AddRange(request.properties.Where(p => p is not null).ToArray());
|
||||
var res = searcher.FindAll().Cast<SearchResult>().Select(r => r.Properties);
|
||||
return res.Any() ? res : throw new NotFoundException();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user