This commit is contained in:
2021-06-29 18:02:12 +00:00
parent 0ee5f7c598
commit fe541dcacd
24 changed files with 658 additions and 658 deletions

View File

@@ -151,40 +151,40 @@ namespace AyaNova.Api.Controllers
}
/// <summary>
/// Duplicate PM
/// </summary>
/// <param name="id">Create a duplicate of this items id</param>
/// <param name="apiVersion">From route path</param>
/// <returns></returns>
[HttpPost("duplicate/{id}")]
public async Task<IActionResult> DuplicatePM([FromRoute] long id, ApiVersion apiVersion)
{
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
// /// <summary>
// /// Duplicate PM
// /// </summary>
// /// <param name="id">Create a duplicate of this items id</param>
// /// <param name="apiVersion">From route path</param>
// /// <returns></returns>
// [HttpPost("duplicate/{id}")]
// public async Task<IActionResult> DuplicatePM([FromRoute] long id, ApiVersion apiVersion)
// {
// if (!serverState.IsOpen)
// return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
//Instantiate the business object handler
PMBiz biz = PMBiz.GetBiz(ct, HttpContext);
// //Instantiate the business object handler
// PMBiz biz = PMBiz.GetBiz(ct, HttpContext);
//If a user has change roles
if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
return StatusCode(403, new ApiNotAuthorizedResponse());
// //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));
// if (!ModelState.IsValid)
// return BadRequest(new ApiErrorResponse(ModelState));
var oSrc = await biz.GetAsync(id, false);
if (oSrc == null)
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
// var oSrc = await biz.GetAsync(id, false);
// if (oSrc == null)
// return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
//Create and validate
PM o = await biz.DuplicateAsync(oSrc);
if (o == null)
return BadRequest(new ApiErrorResponse(biz.Errors));
else
return CreatedAtAction(nameof(PMController.GetPM), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
// //Create and validate
// PM o = await biz.DuplicateAsync(oSrc);
// if (o == null)
// return BadRequest(new ApiErrorResponse(biz.Errors));
// else
// return CreatedAtAction(nameof(PMController.GetPM), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
}
// }