This commit is contained in:
@@ -154,21 +154,15 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get User pick list
|
/// Get User pick list
|
||||||
///
|
///
|
||||||
/// Required roles: Any
|
/// Required roles: Any
|
||||||
///
|
///
|
||||||
/// This list supports querying the Name property
|
|
||||||
/// include a "q" parameter for string to search for
|
|
||||||
/// use % for wildcards.
|
|
||||||
///
|
|
||||||
/// e.g. q=%ohn%
|
|
||||||
///
|
|
||||||
/// Query is case insensitive
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Paged id/name collection of Users with paging data</returns>
|
/// <param name="pagingOptions">Paging, filtering and sorting options</param>
|
||||||
|
/// <returns>Paged id/name collection with paging data</returns>
|
||||||
[HttpGet("PickList", Name = nameof(UserPickList))]
|
[HttpGet("PickList", Name = nameof(UserPickList))]
|
||||||
public async Task<IActionResult> UserPickList([FromQuery] string q, [FromQuery] PagingOptions pagingOptions)
|
public ActionResult UserPickList([FromQuery] PagingOptions pagingOptions)
|
||||||
{
|
{
|
||||||
if (serverState.IsClosed)
|
if (serverState.IsClosed)
|
||||||
{
|
{
|
||||||
@@ -182,7 +176,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
//Instantiate the business object handler
|
//Instantiate the business object handler
|
||||||
UserBiz biz = UserBiz.GetBiz(ct, HttpContext);
|
UserBiz biz = UserBiz.GetBiz(ct, HttpContext);
|
||||||
ApiPagedResponse<NameIdItem> pr = await biz.GetPickListAsync(Url, nameof(UserPickList), pagingOptions, q);
|
ApiPagedResponse<NameIdItem> pr = biz.GetPickList(Url, nameof(UserPickList), pagingOptions);
|
||||||
return Ok(new ApiOkWithPagingResponse<NameIdItem>(pr));
|
return Ok(new ApiOkWithPagingResponse<NameIdItem>(pr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -134,13 +134,13 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get widget pick list
|
/// Get pick list
|
||||||
///
|
///
|
||||||
/// Required roles: Any
|
/// Required roles: Any
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="pagingOptions">Paging, filtering and sorting options</param>
|
/// <param name="pagingOptions">Paging, filtering and sorting options</param>
|
||||||
/// <returns>Paged id/name collection of widgets with paging data</returns>
|
/// <returns>Paged id/name collection with paging data</returns>
|
||||||
[HttpGet("PickList", Name = nameof(WidgetPickList))]
|
[HttpGet("PickList", Name = nameof(WidgetPickList))]
|
||||||
public ActionResult WidgetPickList([FromQuery] PagingOptions pagingOptions)
|
public ActionResult WidgetPickList([FromQuery] PagingOptions pagingOptions)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -172,15 +172,6 @@ namespace AyaNova.Biz
|
|||||||
pagingOptions.Offset = pagingOptions.Offset ?? PagingOptions.DefaultOffset;
|
pagingOptions.Offset = pagingOptions.Offset ?? PagingOptions.DefaultOffset;
|
||||||
pagingOptions.Limit = pagingOptions.Limit ?? PagingOptions.DefaultLimit;
|
pagingOptions.Limit = pagingOptions.Limit ?? PagingOptions.DefaultLimit;
|
||||||
|
|
||||||
// var items = await ct.User
|
|
||||||
// .AsNoTracking()
|
|
||||||
// .OrderBy(m => m.Id)
|
|
||||||
// .Skip(pagingOptions.Offset.Value)
|
|
||||||
// .Take(pagingOptions.Limit.Value)
|
|
||||||
// .ToArrayAsync();
|
|
||||||
|
|
||||||
// var totalRecordCount = await ct.User.CountAsync();
|
|
||||||
// var pageLinks = new PaginationLinkBuilder(Url, routeName, null, pagingOptions, totalRecordCount).PagingLinksObject();
|
|
||||||
|
|
||||||
//BUILD THE QUERY
|
//BUILD THE QUERY
|
||||||
//base query
|
//base query
|
||||||
@@ -233,52 +224,65 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//get picklist (paged)
|
//get picklist (paged)
|
||||||
internal async Task<ApiPagedResponse<NameIdItem>> GetPickListAsync(IUrlHelper Url, string routeName, PagingOptions pagingOptions, string q)
|
internal ApiPagedResponse<NameIdItem> GetPickList(IUrlHelper Url, string routeName, PagingOptions pagingOptions)
|
||||||
{
|
{
|
||||||
|
// pagingOptions.Offset = pagingOptions.Offset ?? PagingOptions.DefaultOffset;
|
||||||
|
// pagingOptions.Limit = pagingOptions.Limit ?? PagingOptions.DefaultLimit;
|
||||||
|
|
||||||
|
// NameIdItem[] items;
|
||||||
|
// int totalRecordCount = 0;
|
||||||
|
|
||||||
|
// if (!string.IsNullOrWhiteSpace(q))
|
||||||
|
// {
|
||||||
|
// items = await ct.User
|
||||||
|
// .AsNoTracking()
|
||||||
|
// .Where(m => EF.Functions.ILike(m.Name, q))
|
||||||
|
// .OrderBy(m => m.Name)
|
||||||
|
// .Skip(pagingOptions.Offset.Value)
|
||||||
|
// .Take(pagingOptions.Limit.Value)
|
||||||
|
// .Select(m => new NameIdItem()
|
||||||
|
// {
|
||||||
|
// Id = m.Id,
|
||||||
|
// Name = m.Name
|
||||||
|
// }).ToArrayAsync();
|
||||||
|
|
||||||
|
// totalRecordCount = await ct.User.Where(m => EF.Functions.ILike(m.Name, q)).CountAsync();
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// items = await ct.User
|
||||||
|
// .AsNoTracking()
|
||||||
|
// .OrderBy(m => m.Name)
|
||||||
|
// .Skip(pagingOptions.Offset.Value)
|
||||||
|
// .Take(pagingOptions.Limit.Value)
|
||||||
|
// .Select(m => new NameIdItem()
|
||||||
|
// {
|
||||||
|
// Id = m.Id,
|
||||||
|
// Name = m.Name
|
||||||
|
// }).ToArrayAsync();
|
||||||
|
|
||||||
|
// totalRecordCount = await ct.User.CountAsync();
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// var pageLinks = new PaginationLinkBuilder(Url, routeName, null, pagingOptions, totalRecordCount).PagingLinksObject();
|
||||||
|
|
||||||
|
// ApiPagedResponse<NameIdItem> pr = new ApiPagedResponse<NameIdItem>(items, pageLinks);
|
||||||
|
// return pr;
|
||||||
|
|
||||||
pagingOptions.Offset = pagingOptions.Offset ?? PagingOptions.DefaultOffset;
|
pagingOptions.Offset = pagingOptions.Offset ?? PagingOptions.DefaultOffset;
|
||||||
pagingOptions.Limit = pagingOptions.Limit ?? PagingOptions.DefaultLimit;
|
pagingOptions.Limit = pagingOptions.Limit ?? PagingOptions.DefaultLimit;
|
||||||
|
|
||||||
NameIdItem[] items;
|
|
||||||
int totalRecordCount = 0;
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(q))
|
var ret = PickListFetcher.GetPickList(ct, UserId, pagingOptions, "auser");
|
||||||
{
|
|
||||||
items = await ct.User
|
|
||||||
.AsNoTracking()
|
|
||||||
.Where(m => EF.Functions.ILike(m.Name, q))
|
|
||||||
.OrderBy(m => m.Name)
|
|
||||||
.Skip(pagingOptions.Offset.Value)
|
|
||||||
.Take(pagingOptions.Limit.Value)
|
|
||||||
.Select(m => new NameIdItem()
|
|
||||||
{
|
|
||||||
Id = m.Id,
|
|
||||||
Name = m.Name
|
|
||||||
}).ToArrayAsync();
|
|
||||||
|
|
||||||
totalRecordCount = await ct.User.Where(m => EF.Functions.ILike(m.Name, q)).CountAsync();
|
var pageLinks = new PaginationLinkBuilder(Url, routeName, null, pagingOptions, ret.TotalRecordCount).PagingLinksObject();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
items = await ct.User
|
|
||||||
.AsNoTracking()
|
|
||||||
.OrderBy(m => m.Name)
|
|
||||||
.Skip(pagingOptions.Offset.Value)
|
|
||||||
.Take(pagingOptions.Limit.Value)
|
|
||||||
.Select(m => new NameIdItem()
|
|
||||||
{
|
|
||||||
Id = m.Id,
|
|
||||||
Name = m.Name
|
|
||||||
}).ToArrayAsync();
|
|
||||||
|
|
||||||
totalRecordCount = await ct.User.CountAsync();
|
ApiPagedResponse<NameIdItem> pr = new ApiPagedResponse<NameIdItem>(ret.Items, pageLinks);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var pageLinks = new PaginationLinkBuilder(Url, routeName, null, pagingOptions, totalRecordCount).PagingLinksObject();
|
|
||||||
|
|
||||||
ApiPagedResponse<NameIdItem> pr = new ApiPagedResponse<NameIdItem>(items, pageLinks);
|
|
||||||
return pr;
|
return pr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -213,7 +213,16 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//get picklist (paged)
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get PickList
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Url"></param>
|
||||||
|
/// <param name="routeName"></param>
|
||||||
|
/// <param name="pagingOptions"></param>
|
||||||
|
/// <returns></returns>
|
||||||
internal ApiPagedResponse<NameIdItem> GetPickList(IUrlHelper Url, string routeName, PagingOptions pagingOptions)
|
internal ApiPagedResponse<NameIdItem> GetPickList(IUrlHelper Url, string routeName, PagingOptions pagingOptions)
|
||||||
{
|
{
|
||||||
pagingOptions.Offset = pagingOptions.Offset ?? PagingOptions.DefaultOffset;
|
pagingOptions.Offset = pagingOptions.Offset ?? PagingOptions.DefaultOffset;
|
||||||
|
|||||||
@@ -113,32 +113,6 @@ namespace raven_integration
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
[Fact]
|
|
||||||
public async void PickListSearchRouteShouldWorkAsExpected()
|
|
||||||
{
|
|
||||||
why isn't this failing now?
|
|
||||||
//CREATE
|
|
||||||
dynamic d = new JObject();
|
|
||||||
d.name = Util.Uniquify("Soft PickListSearchRouteShouldWorkAsExpected");
|
|
||||||
d.created = DateTime.Now.ToString();
|
|
||||||
d.dollarAmount = 1.11m;
|
|
||||||
d.active = true;
|
|
||||||
d.roles = 0;
|
|
||||||
|
|
||||||
ApiResponse r1 = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
|
|
||||||
Util.ValidateDataReturnResponseOk(r1);
|
|
||||||
|
|
||||||
//Get all
|
|
||||||
ApiResponse a = await Util.GetAsync("Widget/picklist?Offset=2&Limit=3&q=%25of%25", await Util.GetTokenAsync("InventoryLimited"));
|
|
||||||
Util.ValidateDataReturnResponseOk(a);
|
|
||||||
Util.ValidateHTTPStatusCode(a, 200);
|
|
||||||
((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Paging test
|
/// Paging test
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user