This commit is contained in:
@@ -51,7 +51,7 @@ namespace AyaNova.Api.Controllers
|
||||
/// Get full widget object
|
||||
///
|
||||
/// Required roles:
|
||||
/// BizAdminFull, InventoryFull, BizAdminLimited, InventoryLimited, TechFull, TechLimited, Accounting
|
||||
/// BizAdminFull, InventoryFull, BizAdminLimited, InventoryLimited
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns>A single widget</returns>
|
||||
@@ -86,7 +86,7 @@ namespace AyaNova.Api.Controllers
|
||||
/// Get filter and sort options
|
||||
///
|
||||
/// Required roles:
|
||||
/// BizAdminFull, InventoryFull, BizAdminLimited, InventoryLimited, TechFull, TechLimited, Accounting
|
||||
/// BizAdminFull, InventoryFull, BizAdminLimited, InventoryLimited
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns>Filter options</returns>
|
||||
@@ -113,7 +113,7 @@ namespace AyaNova.Api.Controllers
|
||||
/// Get paged list of widgets
|
||||
///
|
||||
/// Required roles:
|
||||
/// BizAdminFull, InventoryFull, BizAdminLimited, InventoryLimited, TechFull, TechLimited, Accounting
|
||||
/// 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
|
||||
@@ -167,7 +167,6 @@ namespace AyaNova.Api.Controllers
|
||||
///
|
||||
/// Required roles:
|
||||
/// BizAdminFull, InventoryFull
|
||||
/// TechFull (owned only)
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
@@ -214,7 +213,7 @@ namespace AyaNova.Api.Controllers
|
||||
///
|
||||
/// Required roles:
|
||||
/// BizAdminFull, InventoryFull
|
||||
/// TechFull (owned only)
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="concurrencyToken"></param>
|
||||
@@ -262,7 +261,7 @@ namespace AyaNova.Api.Controllers
|
||||
/// Post widget
|
||||
///
|
||||
/// Required roles:
|
||||
/// BizAdminFull, InventoryFull, TechFull
|
||||
/// BizAdminFull, InventoryFull
|
||||
/// </summary>
|
||||
/// <param name="inObj"></param>
|
||||
/// <returns></returns>
|
||||
@@ -275,7 +274,7 @@ namespace AyaNova.Api.Controllers
|
||||
//Instantiate the business object handler
|
||||
WidgetBiz biz = WidgetBiz.GetBiz(ct, HttpContext);
|
||||
|
||||
//If a user has change roles, or editOwnRoles then they can create, true is passed for isOwner since they are creating so by definition the owner
|
||||
//If a user has change roles
|
||||
if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
|
||||
@@ -291,6 +290,43 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Duplicate widget
|
||||
///
|
||||
/// Required roles:
|
||||
/// BizAdminFull, InventoryFull
|
||||
/// </summary>
|
||||
/// <param name="id">Create a duplicate of this item id</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("duplicate/{id}")]
|
||||
public async Task<IActionResult> DuplicateWidget([FromRoute] long id)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||
|
||||
//Instantiate the business object handler
|
||||
WidgetBiz biz = WidgetBiz.GetBiz(ct, HttpContext);
|
||||
|
||||
//If a user has change roles
|
||||
if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
|
||||
var oSrc = await biz.GetNoLogAsync(id);
|
||||
if (oSrc == null)
|
||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||
|
||||
//Create and validate
|
||||
Widget o = await biz.DuplicateAsync(oSrc);
|
||||
if (o == null)
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
else
|
||||
return CreatedAtAction("GetWidget", new { id = o.Id }, new ApiCreatedResponse(o));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -298,7 +334,7 @@ namespace AyaNova.Api.Controllers
|
||||
///
|
||||
/// Required roles:
|
||||
/// BizAdminFull, InventoryFull
|
||||
/// TechFull (owned only)
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
|
||||
Reference in New Issue
Block a user