Bug Fixes: enrolment, assignment and search order
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Disco.Models.Services.Searching;
|
||||
using Disco.Services.Authorization;
|
||||
using Disco.Services.Interop.ActiveDirectory;
|
||||
using Disco.Services.Searching;
|
||||
using Disco.Services.Web;
|
||||
using System;
|
||||
@@ -13,7 +14,7 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
public partial class SearchController : AuthorizedDatabaseController
|
||||
{
|
||||
[DiscoAuthorizeAny(Claims.Job.Search, Claims.Device.Search, Claims.User.Search)]
|
||||
public virtual ActionResult QuickQuery(string Term, int Limit = 15)
|
||||
public virtual ActionResult QuickQuery(string Term, int Limit = ActiveDirectory.DefaultSearchResultLimit)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Term))
|
||||
throw new ArgumentNullException("Term", "The search query term is required");
|
||||
@@ -36,20 +37,35 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
break;
|
||||
case '@': // User Only
|
||||
if (Authorization.Has(Claims.User.Search))
|
||||
results = results.Concat(Search.SearchUsers(Database, Term.Substring(1), Limit));
|
||||
results = results.Concat(Search.SearchUsers(Database, Term.Substring(1), false, Limit));
|
||||
break;
|
||||
default: // Search All
|
||||
if (Authorization.Has(Claims.Job.Search))
|
||||
results = results.Concat(Search.SearchJobs(Database, Term, Limit));
|
||||
if (Authorization.Has(Claims.User.Search))
|
||||
results = results.Concat(Search.SearchUsers(Database, Term, Limit));
|
||||
results = results.Concat(Search.SearchUsers(Database, Term, false, Limit));
|
||||
if (Authorization.Has(Claims.Device.Search))
|
||||
results = results.Concat(Search.SearchDevices(Database, Term, Limit));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
results = results.OrderByDescending(i => i.ScoreValue.Score(Term)).Take(Limit);
|
||||
results = results.OrderByDescending(i => i.ScoreValues.Score(Term)).Take(Limit);
|
||||
|
||||
return Json(results, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
[DiscoAuthorize(Claims.User.Search)]
|
||||
public virtual ActionResult UsersUpstream(string Term, int Limit = 15)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Term))
|
||||
throw new ArgumentNullException("Term", "The search query term is required");
|
||||
if (Term.Length < 2)
|
||||
throw new ArgumentException("The search query term must be at least two characters", "Term");
|
||||
if (Limit < 1)
|
||||
throw new ArgumentException("The search query limit cannot be less than 1", "Limit");
|
||||
|
||||
var results = Search.SearchUsersUpstream(Database, Term, false, Limit);
|
||||
|
||||
return Json(results, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user