This commit is contained in:
@@ -15,7 +15,7 @@ using AyaNova.Biz;
|
||||
|
||||
namespace AyaNova.Api.Controllers
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sample controller class used during development for testing purposes
|
||||
/// </summary>
|
||||
@@ -50,7 +50,7 @@ namespace AyaNova.Api.Controllers
|
||||
/// Get User
|
||||
///
|
||||
/// Required roles:
|
||||
/// BizAdminFull, InventoryFull, BizAdminLimited, InventoryLimited, TechFull, TechLimited, Accounting
|
||||
/// BizAdminFull, BizAdminLimited
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns>A single User</returns>
|
||||
@@ -93,8 +93,8 @@ namespace AyaNova.Api.Controllers
|
||||
/// <summary>
|
||||
/// Get paged list of Users
|
||||
///
|
||||
/// Required roles:
|
||||
/// BizAdminFull, InventoryFull, BizAdminLimited, InventoryLimited, TechFull, TechLimited, Accounting
|
||||
/// Required roles:
|
||||
/// BizAdminFull, BizAdminLimited
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns>Paged collection of Users with paging data</returns>
|
||||
@@ -129,14 +129,13 @@ namespace AyaNova.Api.Controllers
|
||||
/// <summary>
|
||||
/// Get User pick list
|
||||
///
|
||||
/// Required roles:
|
||||
/// BizAdminFull, InventoryFull, BizAdminLimited, InventoryLimited, TechFull, TechLimited, Accounting
|
||||
/// 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%
|
||||
/// e.g. q=%ohn%
|
||||
///
|
||||
/// Query is case insensitive
|
||||
/// </summary>
|
||||
@@ -149,11 +148,6 @@ namespace AyaNova.Api.Controllers
|
||||
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||
}
|
||||
|
||||
if (!Authorized.IsAuthorizedToRead(HttpContext.Items, AyaType.User))
|
||||
{
|
||||
return StatusCode(401, new ApiNotAuthorizedResponse());
|
||||
}
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
@@ -171,8 +165,7 @@ namespace AyaNova.Api.Controllers
|
||||
/// Put (update) User
|
||||
///
|
||||
/// Required roles:
|
||||
/// BizAdminFull, InventoryFull
|
||||
/// TechFull (owned only)
|
||||
/// BizAdminFull
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
@@ -243,8 +236,8 @@ namespace AyaNova.Api.Controllers
|
||||
/// Patch (update) User
|
||||
///
|
||||
/// Required roles:
|
||||
/// BizAdminFull, InventoryFull
|
||||
/// TechFull (owned only)
|
||||
/// BizAdminFull
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="concurrencyToken"></param>
|
||||
@@ -253,8 +246,6 @@ namespace AyaNova.Api.Controllers
|
||||
[HttpPatch("{id}/{concurrencyToken}")]
|
||||
public async Task<IActionResult> PatchUser([FromRoute] long id, [FromRoute] uint concurrencyToken, [FromBody]JsonPatchDocument<User> objectPatch)
|
||||
{
|
||||
//https://dotnetcoretutorials.com/2017/11/29/json-patch-asp-net-core/
|
||||
|
||||
if (!serverState.IsOpen)
|
||||
{
|
||||
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||
@@ -316,7 +307,8 @@ namespace AyaNova.Api.Controllers
|
||||
/// Post User
|
||||
///
|
||||
/// Required roles:
|
||||
/// BizAdminFull, InventoryFull, TechFull
|
||||
/// BizAdminFull
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="inObj"></param>
|
||||
/// <returns></returns>
|
||||
@@ -371,8 +363,7 @@ namespace AyaNova.Api.Controllers
|
||||
/// Delete User
|
||||
///
|
||||
/// Required roles:
|
||||
/// BizAdminFull, InventoryFull
|
||||
/// TechFull (owned only)
|
||||
/// BizAdminFull
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
@@ -380,7 +371,6 @@ namespace AyaNova.Api.Controllers
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> DeleteUser([FromRoute] long id)
|
||||
{
|
||||
|
||||
if (!serverState.IsOpen)
|
||||
{
|
||||
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||
@@ -422,82 +412,13 @@ namespace AyaNova.Api.Controllers
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private bool UserExists(long id)
|
||||
{
|
||||
return ct.User.Any(e => e.Id == id);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get route that triggers exception for testing
|
||||
/// </summary>
|
||||
/// <returns>Nothing, triggers exception</returns>
|
||||
[HttpGet("exception")]
|
||||
public ActionResult GetException()
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
{
|
||||
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||
}
|
||||
|
||||
if (!Authorized.IsAuthorizedToRead(HttpContext.Items, AyaType.User))
|
||||
{
|
||||
return StatusCode(401, new ApiNotAuthorizedResponse());
|
||||
}
|
||||
|
||||
throw new System.NotSupportedException("Test exception from User controller");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get route that triggers an alternate type of exception for testing
|
||||
/// </summary>
|
||||
/// <returns>Nothing, triggers exception</returns>
|
||||
[HttpGet("altexception")]
|
||||
public ActionResult GetAltException()
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
{
|
||||
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||
}
|
||||
|
||||
if (!Authorized.IsAuthorizedToRead(HttpContext.Items, AyaType.User))
|
||||
{
|
||||
return StatusCode(401, new ApiNotAuthorizedResponse());
|
||||
}
|
||||
|
||||
throw new System.ArgumentException("Test exception (ALT) from User controller");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get route that submits a long running operation job for testing
|
||||
/// </summary>
|
||||
/// <returns>Nothing</returns>
|
||||
[HttpGet("TestUserJob")]
|
||||
public ActionResult TestUserJob()
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
{
|
||||
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||
}
|
||||
|
||||
if (!Authorized.IsAuthorizedToModify(HttpContext.Items, AyaType.JobOperations))
|
||||
{
|
||||
return StatusCode(401, new ApiNotAuthorizedResponse());
|
||||
}
|
||||
|
||||
//Create the job here
|
||||
OpsJob j = new OpsJob();
|
||||
j.Name = "TestUserJob";
|
||||
j.JobType = JobType.TestUserJob;
|
||||
JobsBiz.AddJob(j, ct);
|
||||
return Accepted(new { JobId = j.GId });//202 accepted
|
||||
}
|
||||
|
||||
|
||||
//------------
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}//eoc
|
||||
}//eons
|
||||
Reference in New Issue
Block a user