This commit is contained in:
@@ -133,52 +133,16 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// /// Get widget pick list
|
||||
// ///
|
||||
// /// 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=%Jones%
|
||||
// ///
|
||||
// /// Query is case insensitive
|
||||
// /// </summary>
|
||||
// /// <returns>Paged id/name collection of widgets with paging data</returns>
|
||||
// [HttpGet("PickList", Name = nameof(WidgetPickList))]
|
||||
// public async Task<IActionResult> WidgetPickList([FromQuery] string q, [FromQuery] PagingOptions pagingOptions)
|
||||
// {
|
||||
// if (serverState.IsClosed)
|
||||
// return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||
|
||||
// if (!ModelState.IsValid)
|
||||
// return BadRequest(new ApiErrorResponse(ModelState));
|
||||
|
||||
// //Instantiate the business object handler
|
||||
// WidgetBiz biz = WidgetBiz.GetBiz(ct, HttpContext);
|
||||
|
||||
// ApiPagedResponse<NameIdItem> pr = await biz.GetPickListAsync(Url, nameof(WidgetPickList), pagingOptions, q);
|
||||
// return Ok(new ApiOkWithPagingResponse<NameIdItem>(pr));
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// Get widget pick list
|
||||
/// <summary>
|
||||
/// Get widget pick list
|
||||
///
|
||||
/// 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=%Jones%
|
||||
///
|
||||
/// Query is case insensitive
|
||||
/// </summary>
|
||||
/// <returns>Paged id/name collection of widgets with paging data</returns>
|
||||
/// <param name="pagingOptions">Paging, filtering and sorting options</param>
|
||||
/// <returns>Paged id/name collection of widgets with paging data</returns>
|
||||
[HttpGet("PickList", Name = nameof(WidgetPickList))]
|
||||
public async Task<IActionResult> WidgetPickList([FromQuery] PagingOptions pagingOptions)
|
||||
public ActionResult WidgetPickList([FromQuery] PagingOptions pagingOptions)
|
||||
{
|
||||
if (serverState.IsClosed)
|
||||
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||
@@ -189,10 +153,10 @@ namespace AyaNova.Api.Controllers
|
||||
//Instantiate the business object handler
|
||||
WidgetBiz biz = WidgetBiz.GetBiz(ct, HttpContext);
|
||||
|
||||
ApiPagedResponse<NameIdItem> pr = await biz.GetPickListAsync(Url, nameof(WidgetPickList), pagingOptions);
|
||||
ApiPagedResponse<NameIdItem> pr = biz.GetPickList(Url, nameof(WidgetPickList), pagingOptions);
|
||||
return Ok(new ApiOkWithPagingResponse<NameIdItem>(pr));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Put (update) widget
|
||||
|
||||
@@ -214,82 +214,11 @@ namespace AyaNova.Biz
|
||||
|
||||
|
||||
//get picklist (paged)
|
||||
internal async Task<ApiPagedResponse<NameIdItem>> GetPickListAsync(IUrlHelper Url, string routeName, PagingOptions pagingOptions)
|
||||
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;
|
||||
|
||||
// //BUILD THE QUERY
|
||||
// //base query
|
||||
// var q = "SELECT id, name FROM AWIDGET ";
|
||||
|
||||
// //GET THE FILTER / SORT
|
||||
// if (pagingOptions.DataFilterId > 0)
|
||||
// {
|
||||
// var TheFilter = await ct.DataFilter.FirstOrDefaultAsync(x => x.Id == pagingOptions.DataFilterId);
|
||||
|
||||
// //BUILD WHERE AND APPEND IT
|
||||
// q = q + FilterSqlCriteriaBuilder.DataFilterToSQLCriteria(TheFilter, WidgetBiz.FilterOptions(), UserId);
|
||||
|
||||
// //BUILD ORDER BY AND APPEND IT
|
||||
// q = q + FilterSqlOrderByBuilder.DataFilterToSQLOrderBy(TheFilter);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //GET DEFAULT ORDER BY
|
||||
// q = q + FilterSqlOrderByBuilder.DefaultOrderBy();
|
||||
// }
|
||||
|
||||
|
||||
// #pragma warning disable EF1000
|
||||
|
||||
// var items = await ct.Widget
|
||||
// .AsNoTracking()
|
||||
// .FromSql(q)
|
||||
// .Skip(pagingOptions.Offset.Value)
|
||||
// .Take(pagingOptions.Limit.Value)
|
||||
// .ToArrayAsync();
|
||||
|
||||
// var totalRecordCount = await ct.Widget
|
||||
// .AsNoTracking()
|
||||
// .FromSql(q)
|
||||
// .CountAsync();
|
||||
// #pragma warning restore EF1000
|
||||
|
||||
// if (!string.IsNullOrWhiteSpace(q))
|
||||
// {
|
||||
// items = await ct.Widget
|
||||
// .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.Widget.Where(m => EF.Functions.ILike(m.Name, q)).CountAsync();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// items = await ct.Widget
|
||||
// .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.Widget.CountAsync();
|
||||
// }
|
||||
|
||||
var ret = PickListFetcher.GetPickList(ct, UserId, pagingOptions, "awidget");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user