This commit is contained in:
@@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.JsonPatch;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
using AyaNova.Models;
|
||||
using AyaNova.Api.ControllerHelpers;
|
||||
@@ -109,45 +110,16 @@ namespace AyaNova.Api.Controllers
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get paged list of widgets
|
||||
/// Get list for selection / viewing
|
||||
///
|
||||
/// Required roles:
|
||||
/// BizAdminFull, InventoryFull, BizAdminLimited, InventoryLimited
|
||||
/// </summary>
|
||||
/// <returns>Paged collection of widgets with paging data</returns>
|
||||
[HttpGet("ListWidgets", Name = nameof(ListWidgets))]//We MUST have a "Name" defined or we can't get the link for the pagination, non paged urls don't need a name
|
||||
public async Task<IActionResult> ListWidgets([FromQuery] ListOptions pagingOptions)
|
||||
{
|
||||
if (serverState.IsClosed)
|
||||
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||
|
||||
//Instantiate the business object handler
|
||||
WidgetBiz biz = WidgetBiz.GetBiz(ct, HttpContext);
|
||||
|
||||
if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
|
||||
ApiPagedResponse<Widget> pr = await biz.GetManyAsync(Url, nameof(ListWidgets), pagingOptions);
|
||||
return Ok(new ApiOkWithPagingResponse<Widget>(pr));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get pick list
|
||||
///
|
||||
/// Required roles: Any
|
||||
/// Required roles: Any (some roles might have restrictions on exact fields that are returned)
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="pagingOptions">Paging, filtering and sorting options</param>
|
||||
/// <returns>Paged id/name collection with paging data</returns>
|
||||
[HttpGet("PickList", Name = nameof(WidgetPickList))]
|
||||
public ActionResult WidgetPickList([FromQuery] ListOptions pagingOptions)
|
||||
/// <returns>Collection with paging data</returns>
|
||||
[HttpGet("List", Name = nameof(WidgetList))]
|
||||
public ActionResult WidgetList([FromQuery] ListOptions pagingOptions)
|
||||
{
|
||||
if (serverState.IsClosed)
|
||||
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||
@@ -158,11 +130,66 @@ namespace AyaNova.Api.Controllers
|
||||
//Instantiate the business object handler
|
||||
WidgetBiz biz = WidgetBiz.GetBiz(ct, HttpContext);
|
||||
|
||||
ApiPagedResponse<NameIdItem> pr = biz.GetPickList(Url, nameof(WidgetPickList), pagingOptions);
|
||||
return Ok(new ApiOkWithPagingResponse<NameIdItem>(pr));
|
||||
// ApiPagedResponse<NameIdItem> pr = biz.GetList(Url, nameof(WidgetList), pagingOptions);
|
||||
// return Ok(new ApiOkWithPagingResponse<NameIdItem>(pr));
|
||||
JObject j = biz.GetList(Url, nameof(WidgetList), pagingOptions).Result;
|
||||
return Ok(j);
|
||||
}
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// /// Get paged list of widgets
|
||||
// ///
|
||||
// /// Required roles:
|
||||
// /// BizAdminFull, InventoryFull, BizAdminLimited, InventoryLimited
|
||||
// /// </summary>
|
||||
// /// <returns>Paged collection of widgets with paging data</returns>
|
||||
// [HttpGet("ListWidgets", Name = nameof(ListWidgets))]//We MUST have a "Name" defined or we can't get the link for the pagination, non paged urls don't need a name
|
||||
// public async Task<IActionResult> ListWidgets([FromQuery] ListOptions pagingOptions)
|
||||
// {
|
||||
// if (serverState.IsClosed)
|
||||
// return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||
|
||||
// //Instantiate the business object handler
|
||||
// WidgetBiz biz = WidgetBiz.GetBiz(ct, HttpContext);
|
||||
|
||||
// if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType))
|
||||
// return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
|
||||
// if (!ModelState.IsValid)
|
||||
// return BadRequest(new ApiErrorResponse(ModelState));
|
||||
|
||||
// ApiPagedResponse<Widget> pr = await biz.GetManyAsync(Url, nameof(ListWidgets), pagingOptions);
|
||||
// return Ok(new ApiOkWithPagingResponse<Widget>(pr));
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// /// Get pick list
|
||||
// ///
|
||||
// /// Required roles: Any
|
||||
// ///
|
||||
// /// </summary>
|
||||
// /// <param name="pagingOptions">Paging, filtering and sorting options</param>
|
||||
// /// <returns>Paged id/name collection with paging data</returns>
|
||||
// [HttpGet("PickList", Name = nameof(WidgetPickList))]
|
||||
// public ActionResult WidgetPickList([FromQuery] ListOptions 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 = biz.GetPickList(Url, nameof(WidgetPickList), pagingOptions);
|
||||
// return Ok(new ApiOkWithPagingResponse<NameIdItem>(pr));
|
||||
// }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Put (update) widget
|
||||
///
|
||||
@@ -287,9 +314,9 @@ namespace AyaNova.Api.Controllers
|
||||
Widget o = await biz.CreateAsync(inObj);
|
||||
if (o == null)
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
else
|
||||
else
|
||||
return CreatedAtAction(nameof(WidgetController.GetWidget), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user