Remove PATCH
This commit is contained in:
@@ -114,52 +114,6 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Patch (update) Contract
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="concurrencyToken"></param>
|
|
||||||
/// <param name="objectPatch"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPatch("{id}/{concurrencyToken}")]
|
|
||||||
public async Task<IActionResult> PatchContract([FromRoute] long id, [FromRoute] uint concurrencyToken, [FromBody]JsonPatchDocument<Contract> objectPatch)
|
|
||||||
{
|
|
||||||
//https://dotnetcoretutorials.com/2017/11/29/json-patch-asp-net-core/
|
|
||||||
|
|
||||||
if (!serverState.IsOpen)
|
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
|
||||||
|
|
||||||
//Instantiate the business object handler
|
|
||||||
ContractBiz biz = ContractBiz.GetBiz(ct, HttpContext);
|
|
||||||
|
|
||||||
var o = await biz.GetAsync(id, false);
|
|
||||||
if (o == null)
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
|
|
||||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//patch and validate
|
|
||||||
if (!await biz.PatchAsync(o, objectPatch, concurrencyToken))
|
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
|
||||||
}
|
|
||||||
catch (DbUpdateConcurrencyException)
|
|
||||||
{
|
|
||||||
if (!await biz.ExistsAsync(id))
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
else
|
|
||||||
return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT));
|
|
||||||
}
|
|
||||||
return Ok(ApiOkResponse.Response(new { ConcurrencyToken = o.ConcurrencyToken }, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Post Contract
|
/// Post Contract
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -112,53 +112,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
return Ok(ApiOkResponse.Response(new { ConcurrencyToken = o.ConcurrencyToken }, true));
|
return Ok(ApiOkResponse.Response(new { ConcurrencyToken = o.ConcurrencyToken }, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Patch (update) Customer
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="concurrencyToken"></param>
|
|
||||||
/// <param name="objectPatch"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPatch("{id}/{concurrencyToken}")]
|
|
||||||
public async Task<IActionResult> PatchCustomer([FromRoute] long id, [FromRoute] uint concurrencyToken, [FromBody]JsonPatchDocument<Customer> objectPatch)
|
|
||||||
{
|
|
||||||
//https://dotnetcoretutorials.com/2017/11/29/json-patch-asp-net-core/
|
|
||||||
|
|
||||||
if (!serverState.IsOpen)
|
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
|
||||||
|
|
||||||
//Instantiate the business object handler
|
|
||||||
CustomerBiz biz = CustomerBiz.GetBiz(ct, HttpContext);
|
|
||||||
|
|
||||||
var o = await biz.GetAsync(id, false);
|
|
||||||
if (o == null)
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
|
|
||||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//patch and validate
|
|
||||||
if (!await biz.PatchAsync(o, objectPatch, concurrencyToken))
|
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
|
||||||
}
|
|
||||||
catch (DbUpdateConcurrencyException)
|
|
||||||
{
|
|
||||||
if (!await biz.ExistsAsync(id))
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
else
|
|
||||||
return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT));
|
|
||||||
}
|
|
||||||
return Ok(ApiOkResponse.Response(new { ConcurrencyToken = o.ConcurrencyToken }, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Post Customer
|
/// Post Customer
|
||||||
|
|||||||
@@ -113,53 +113,6 @@ namespace AyaNova.Api.Controllers
|
|||||||
return Ok(ApiOkResponse.Response(new { ConcurrencyToken = o.ConcurrencyToken }, true));
|
return Ok(ApiOkResponse.Response(new { ConcurrencyToken = o.ConcurrencyToken }, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Patch (update) HeadOffice
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="concurrencyToken"></param>
|
|
||||||
/// <param name="objectPatch"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPatch("{id}/{concurrencyToken}")]
|
|
||||||
public async Task<IActionResult> PatchHeadOffice([FromRoute] long id, [FromRoute] uint concurrencyToken, [FromBody]JsonPatchDocument<HeadOffice> objectPatch)
|
|
||||||
{
|
|
||||||
//https://dotnetcoretutorials.com/2017/11/29/json-patch-asp-net-core/
|
|
||||||
|
|
||||||
if (!serverState.IsOpen)
|
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
|
||||||
|
|
||||||
//Instantiate the business object handler
|
|
||||||
HeadOfficeBiz biz = HeadOfficeBiz.GetBiz(ct, HttpContext);
|
|
||||||
|
|
||||||
var o = await biz.GetAsync(id, false);
|
|
||||||
if (o == null)
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
|
|
||||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//patch and validate
|
|
||||||
if (!await biz.PatchAsync(o, objectPatch, concurrencyToken))
|
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
|
||||||
}
|
|
||||||
catch (DbUpdateConcurrencyException)
|
|
||||||
{
|
|
||||||
if (!await biz.ExistsAsync(id))
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
else
|
|
||||||
return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT));
|
|
||||||
}
|
|
||||||
return Ok(ApiOkResponse.Response(new { ConcurrencyToken = o.ConcurrencyToken }, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Post HeadOffice
|
/// Post HeadOffice
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -114,52 +114,6 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Patch (update) LoanUnit
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="concurrencyToken"></param>
|
|
||||||
/// <param name="objectPatch"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPatch("{id}/{concurrencyToken}")]
|
|
||||||
public async Task<IActionResult> PatchLoanUnit([FromRoute] long id, [FromRoute] uint concurrencyToken, [FromBody]JsonPatchDocument<LoanUnit> objectPatch)
|
|
||||||
{
|
|
||||||
//https://dotnetcoretutorials.com/2017/11/29/json-patch-asp-net-core/
|
|
||||||
|
|
||||||
if (!serverState.IsOpen)
|
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
|
||||||
|
|
||||||
//Instantiate the business object handler
|
|
||||||
LoanUnitBiz biz = LoanUnitBiz.GetBiz(ct, HttpContext);
|
|
||||||
|
|
||||||
var o = await biz.GetAsync(id, false);
|
|
||||||
if (o == null)
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
|
|
||||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//patch and validate
|
|
||||||
if (!await biz.PatchAsync(o, objectPatch, concurrencyToken))
|
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
|
||||||
}
|
|
||||||
catch (DbUpdateConcurrencyException)
|
|
||||||
{
|
|
||||||
if (!await biz.ExistsAsync(id))
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
else
|
|
||||||
return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT));
|
|
||||||
}
|
|
||||||
return Ok(ApiOkResponse.Response(new { ConcurrencyToken = o.ConcurrencyToken }, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Post LoanUnit
|
/// Post LoanUnit
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -114,52 +114,6 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Patch (update) PMTemplate
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="concurrencyToken"></param>
|
|
||||||
/// <param name="objectPatch"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPatch("{id}/{concurrencyToken}")]
|
|
||||||
public async Task<IActionResult> PatchPMTemplate([FromRoute] long id, [FromRoute] uint concurrencyToken, [FromBody]JsonPatchDocument<PMTemplate> objectPatch)
|
|
||||||
{
|
|
||||||
//https://dotnetcoretutorials.com/2017/11/29/json-patch-asp-net-core/
|
|
||||||
|
|
||||||
if (!serverState.IsOpen)
|
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
|
||||||
|
|
||||||
//Instantiate the business object handler
|
|
||||||
PMTemplateBiz biz = PMTemplateBiz.GetBiz(ct, HttpContext);
|
|
||||||
|
|
||||||
var o = await biz.GetAsync(id, false);
|
|
||||||
if (o == null)
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
|
|
||||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//patch and validate
|
|
||||||
if (!await biz.PatchAsync(o, objectPatch, concurrencyToken))
|
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
|
||||||
}
|
|
||||||
catch (DbUpdateConcurrencyException)
|
|
||||||
{
|
|
||||||
if (!await biz.ExistsAsync(id))
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
else
|
|
||||||
return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT));
|
|
||||||
}
|
|
||||||
return Ok(ApiOkResponse.Response(new { ConcurrencyToken = o.ConcurrencyToken }, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Post PMTemplate
|
/// Post PMTemplate
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -114,52 +114,6 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Patch (update) Part
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="concurrencyToken"></param>
|
|
||||||
/// <param name="objectPatch"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPatch("{id}/{concurrencyToken}")]
|
|
||||||
public async Task<IActionResult> PatchPart([FromRoute] long id, [FromRoute] uint concurrencyToken, [FromBody]JsonPatchDocument<Part> objectPatch)
|
|
||||||
{
|
|
||||||
//https://dotnetcoretutorials.com/2017/11/29/json-patch-asp-net-core/
|
|
||||||
|
|
||||||
if (!serverState.IsOpen)
|
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
|
||||||
|
|
||||||
//Instantiate the business object handler
|
|
||||||
PartBiz biz = PartBiz.GetBiz(ct, HttpContext);
|
|
||||||
|
|
||||||
var o = await biz.GetAsync(id, false);
|
|
||||||
if (o == null)
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
|
|
||||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//patch and validate
|
|
||||||
if (!await biz.PatchAsync(o, objectPatch, concurrencyToken))
|
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
|
||||||
}
|
|
||||||
catch (DbUpdateConcurrencyException)
|
|
||||||
{
|
|
||||||
if (!await biz.ExistsAsync(id))
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
else
|
|
||||||
return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT));
|
|
||||||
}
|
|
||||||
return Ok(ApiOkResponse.Response(new { ConcurrencyToken = o.ConcurrencyToken }, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Post Part
|
/// Post Part
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -113,53 +113,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
return Ok(ApiOkResponse.Response(new { ConcurrencyToken = o.ConcurrencyToken }, true));
|
return Ok(ApiOkResponse.Response(new { ConcurrencyToken = o.ConcurrencyToken }, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Patch (update) Project
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="concurrencyToken"></param>
|
|
||||||
/// <param name="objectPatch"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPatch("{id}/{concurrencyToken}")]
|
|
||||||
public async Task<IActionResult> PatchProject([FromRoute] long id, [FromRoute] uint concurrencyToken, [FromBody]JsonPatchDocument<Project> objectPatch)
|
|
||||||
{
|
|
||||||
//https://dotnetcoretutorials.com/2017/11/29/json-patch-asp-net-core/
|
|
||||||
|
|
||||||
if (!serverState.IsOpen)
|
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
|
||||||
|
|
||||||
//Instantiate the business object handler
|
|
||||||
ProjectBiz biz = ProjectBiz.GetBiz(ct, HttpContext);
|
|
||||||
|
|
||||||
var o = await biz.GetAsync(id, false);
|
|
||||||
if (o == null)
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
|
|
||||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//patch and validate
|
|
||||||
if (!await biz.PatchAsync(o, objectPatch, concurrencyToken))
|
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
|
||||||
}
|
|
||||||
catch (DbUpdateConcurrencyException)
|
|
||||||
{
|
|
||||||
if (!await biz.ExistsAsync(id))
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
else
|
|
||||||
return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT));
|
|
||||||
}
|
|
||||||
return Ok(ApiOkResponse.Response(new { ConcurrencyToken = o.ConcurrencyToken }, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Post Project
|
/// Post Project
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -114,52 +114,6 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Patch (update) PurchaseOrder
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="concurrencyToken"></param>
|
|
||||||
/// <param name="objectPatch"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPatch("{id}/{concurrencyToken}")]
|
|
||||||
public async Task<IActionResult> PatchPurchaseOrder([FromRoute] long id, [FromRoute] uint concurrencyToken, [FromBody]JsonPatchDocument<PurchaseOrder> objectPatch)
|
|
||||||
{
|
|
||||||
//https://dotnetcoretutorials.com/2017/11/29/json-patch-asp-net-core/
|
|
||||||
|
|
||||||
if (!serverState.IsOpen)
|
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
|
||||||
|
|
||||||
//Instantiate the business object handler
|
|
||||||
PurchaseOrderBiz biz = PurchaseOrderBiz.GetBiz(ct, HttpContext);
|
|
||||||
|
|
||||||
var o = await biz.GetAsync(id, false);
|
|
||||||
if (o == null)
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
|
|
||||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//patch and validate
|
|
||||||
if (!await biz.PatchAsync(o, objectPatch, concurrencyToken))
|
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
|
||||||
}
|
|
||||||
catch (DbUpdateConcurrencyException)
|
|
||||||
{
|
|
||||||
if (!await biz.ExistsAsync(id))
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
else
|
|
||||||
return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT));
|
|
||||||
}
|
|
||||||
return Ok(ApiOkResponse.Response(new { ConcurrencyToken = o.ConcurrencyToken }, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Post PurchaseOrder
|
/// Post PurchaseOrder
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -114,52 +114,6 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Patch (update) QuoteTemplate
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="concurrencyToken"></param>
|
|
||||||
/// <param name="objectPatch"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPatch("{id}/{concurrencyToken}")]
|
|
||||||
public async Task<IActionResult> PatchQuoteTemplate([FromRoute] long id, [FromRoute] uint concurrencyToken, [FromBody]JsonPatchDocument<QuoteTemplate> objectPatch)
|
|
||||||
{
|
|
||||||
//https://dotnetcoretutorials.com/2017/11/29/json-patch-asp-net-core/
|
|
||||||
|
|
||||||
if (!serverState.IsOpen)
|
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
|
||||||
|
|
||||||
//Instantiate the business object handler
|
|
||||||
QuoteTemplateBiz biz = QuoteTemplateBiz.GetBiz(ct, HttpContext);
|
|
||||||
|
|
||||||
var o = await biz.GetAsync(id, false);
|
|
||||||
if (o == null)
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
|
|
||||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//patch and validate
|
|
||||||
if (!await biz.PatchAsync(o, objectPatch, concurrencyToken))
|
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
|
||||||
}
|
|
||||||
catch (DbUpdateConcurrencyException)
|
|
||||||
{
|
|
||||||
if (!await biz.ExistsAsync(id))
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
else
|
|
||||||
return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT));
|
|
||||||
}
|
|
||||||
return Ok(ApiOkResponse.Response(new { ConcurrencyToken = o.ConcurrencyToken }, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Post QuoteTemplate
|
/// Post QuoteTemplate
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -114,52 +114,6 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Patch (update) Unit
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="concurrencyToken"></param>
|
|
||||||
/// <param name="objectPatch"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPatch("{id}/{concurrencyToken}")]
|
|
||||||
public async Task<IActionResult> PatchUnit([FromRoute] long id, [FromRoute] uint concurrencyToken, [FromBody]JsonPatchDocument<Unit> objectPatch)
|
|
||||||
{
|
|
||||||
//https://dotnetcoretutorials.com/2017/11/29/json-patch-asp-net-core/
|
|
||||||
|
|
||||||
if (!serverState.IsOpen)
|
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
|
||||||
|
|
||||||
//Instantiate the business object handler
|
|
||||||
UnitBiz biz = UnitBiz.GetBiz(ct, HttpContext);
|
|
||||||
|
|
||||||
var o = await biz.GetAsync(id, false);
|
|
||||||
if (o == null)
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
|
|
||||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//patch and validate
|
|
||||||
if (!await biz.PatchAsync(o, objectPatch, concurrencyToken))
|
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
|
||||||
}
|
|
||||||
catch (DbUpdateConcurrencyException)
|
|
||||||
{
|
|
||||||
if (!await biz.ExistsAsync(id))
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
else
|
|
||||||
return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT));
|
|
||||||
}
|
|
||||||
return Ok(ApiOkResponse.Response(new { ConcurrencyToken = o.ConcurrencyToken }, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Post Unit
|
/// Post Unit
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -114,52 +114,6 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Patch (update) UnitModel
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="concurrencyToken"></param>
|
|
||||||
/// <param name="objectPatch"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPatch("{id}/{concurrencyToken}")]
|
|
||||||
public async Task<IActionResult> PatchUnitModel([FromRoute] long id, [FromRoute] uint concurrencyToken, [FromBody]JsonPatchDocument<UnitModel> objectPatch)
|
|
||||||
{
|
|
||||||
//https://dotnetcoretutorials.com/2017/11/29/json-patch-asp-net-core/
|
|
||||||
|
|
||||||
if (!serverState.IsOpen)
|
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
|
||||||
|
|
||||||
//Instantiate the business object handler
|
|
||||||
UnitModelBiz biz = UnitModelBiz.GetBiz(ct, HttpContext);
|
|
||||||
|
|
||||||
var o = await biz.GetAsync(id, false);
|
|
||||||
if (o == null)
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
|
|
||||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//patch and validate
|
|
||||||
if (!await biz.PatchAsync(o, objectPatch, concurrencyToken))
|
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
|
||||||
}
|
|
||||||
catch (DbUpdateConcurrencyException)
|
|
||||||
{
|
|
||||||
if (!await biz.ExistsAsync(id))
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
else
|
|
||||||
return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT));
|
|
||||||
}
|
|
||||||
return Ok(ApiOkResponse.Response(new { ConcurrencyToken = o.ConcurrencyToken }, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Post UnitModel
|
/// Post UnitModel
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -143,62 +143,6 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Patch (update) User
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="concurrencyToken"></param>
|
|
||||||
/// <param name="objectPatch"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPatch("{id}/{concurrencyToken}")]
|
|
||||||
public async Task<IActionResult> PatchUser([FromRoute] long id, [FromRoute] uint concurrencyToken, [FromBody]JsonPatchDocument<User> objectPatch)
|
|
||||||
{
|
|
||||||
if (!serverState.IsOpen)
|
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
|
||||||
{
|
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
|
||||||
}
|
|
||||||
|
|
||||||
//Instantiate the business object handler
|
|
||||||
UserBiz biz = UserBiz.GetBiz(ct, HttpContext);
|
|
||||||
var o = await ct.User.SingleOrDefaultAsync(m => m.Id == id);
|
|
||||||
|
|
||||||
if (o == null)
|
|
||||||
{
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
|
||||||
{
|
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//patch and validate
|
|
||||||
if (!await biz.PatchAsync(o, objectPatch, concurrencyToken))
|
|
||||||
{
|
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (DbUpdateConcurrencyException)
|
|
||||||
{
|
|
||||||
if (!UserExists(id))
|
|
||||||
{
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ok(ApiOkResponse.Response(new { ConcurrencyToken = o.ConcurrencyToken }, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Post User
|
/// Post User
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -143,67 +143,6 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Patch (update) UserOptions
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id">UserId</param>
|
|
||||||
/// <param name="concurrencyToken"></param>
|
|
||||||
/// <param name="objectPatch"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPatch("{id}/{concurrencyToken}")]
|
|
||||||
public async Task<IActionResult> PatchUserOptions([FromRoute] long id, [FromRoute] uint concurrencyToken, [FromBody]JsonPatchDocument<UserOptions> objectPatch)
|
|
||||||
{
|
|
||||||
if (!serverState.IsClosed)
|
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
|
||||||
{
|
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
|
||||||
}
|
|
||||||
|
|
||||||
var UserId = UserIdFromContext.Id(HttpContext.Items);
|
|
||||||
|
|
||||||
//Instantiate the business object handler
|
|
||||||
UserOptionsBiz biz = new UserOptionsBiz(ct, UserId, UserRolesFromContext.Roles(HttpContext.Items));
|
|
||||||
|
|
||||||
var o = await ct.UserOptions.SingleOrDefaultAsync(m => m.UserId == id);
|
|
||||||
|
|
||||||
if (o == null)
|
|
||||||
{
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (id != UserId && !Authorized.HasModifyRole(HttpContext.Items, AyaType.UserOptions))
|
|
||||||
{
|
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//patch and validate
|
|
||||||
if (!await biz.PatchAsync(o, objectPatch, concurrencyToken))
|
|
||||||
{
|
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (DbUpdateConcurrencyException)
|
|
||||||
{
|
|
||||||
if (!UserOptionsExists(id))
|
|
||||||
{
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ok(ApiOkResponse.Response(new { ConcurrencyToken = o.ConcurrencyToken }, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private bool UserOptionsExists(long id)
|
private bool UserOptionsExists(long id)
|
||||||
{
|
{
|
||||||
//NOTE: checks by UserId, NOT by Id as in most other objects
|
//NOTE: checks by UserId, NOT by Id as in most other objects
|
||||||
|
|||||||
@@ -114,52 +114,6 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Patch (update) Vendor
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="concurrencyToken"></param>
|
|
||||||
/// <param name="objectPatch"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPatch("{id}/{concurrencyToken}")]
|
|
||||||
public async Task<IActionResult> PatchVendor([FromRoute] long id, [FromRoute] uint concurrencyToken, [FromBody]JsonPatchDocument<Vendor> objectPatch)
|
|
||||||
{
|
|
||||||
//https://dotnetcoretutorials.com/2017/11/29/json-patch-asp-net-core/
|
|
||||||
|
|
||||||
if (!serverState.IsOpen)
|
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
|
||||||
|
|
||||||
//Instantiate the business object handler
|
|
||||||
VendorBiz biz = VendorBiz.GetBiz(ct, HttpContext);
|
|
||||||
|
|
||||||
var o = await biz.GetAsync(id, false);
|
|
||||||
if (o == null)
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
|
|
||||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//patch and validate
|
|
||||||
if (!await biz.PatchAsync(o, objectPatch, concurrencyToken))
|
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
|
||||||
}
|
|
||||||
catch (DbUpdateConcurrencyException)
|
|
||||||
{
|
|
||||||
if (!await biz.ExistsAsync(id))
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
else
|
|
||||||
return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT));
|
|
||||||
}
|
|
||||||
return Ok(ApiOkResponse.Response(new { ConcurrencyToken = o.ConcurrencyToken }, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Post Vendor
|
/// Post Vendor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -121,52 +121,6 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Patch (update) widget
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="concurrencyToken"></param>
|
|
||||||
/// <param name="objectPatch"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPatch("{id}/{concurrencyToken}")]
|
|
||||||
public async Task<IActionResult> PatchWidget([FromRoute] long id, [FromRoute] uint concurrencyToken, [FromBody]JsonPatchDocument<Widget> objectPatch)
|
|
||||||
{
|
|
||||||
//https://dotnetcoretutorials.com/2017/11/29/json-patch-asp-net-core/
|
|
||||||
|
|
||||||
if (!serverState.IsOpen)
|
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
|
||||||
|
|
||||||
//Instantiate the business object handler
|
|
||||||
WidgetBiz biz = WidgetBiz.GetBiz(ct, HttpContext);
|
|
||||||
|
|
||||||
var o = await biz.GetAsync(id, false);
|
|
||||||
if (o == null)
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
|
|
||||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//patch and validate
|
|
||||||
if (!await biz.PatchAsync(o, objectPatch, concurrencyToken))
|
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
|
||||||
}
|
|
||||||
catch (DbUpdateConcurrencyException)
|
|
||||||
{
|
|
||||||
if (!await biz.ExistsAsync(id))
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
else
|
|
||||||
return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT));
|
|
||||||
}
|
|
||||||
return Ok(ApiOkResponse.Response(new { ConcurrencyToken = o.ConcurrencyToken }, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Post widget
|
/// Post widget
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -114,52 +114,6 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Patch (update) WorkOrderTemplate
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="concurrencyToken"></param>
|
|
||||||
/// <param name="objectPatch"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPatch("{id}/{concurrencyToken}")]
|
|
||||||
public async Task<IActionResult> PatchWorkOrderTemplate([FromRoute] long id, [FromRoute] uint concurrencyToken, [FromBody]JsonPatchDocument<WorkOrderTemplate> objectPatch)
|
|
||||||
{
|
|
||||||
//https://dotnetcoretutorials.com/2017/11/29/json-patch-asp-net-core/
|
|
||||||
|
|
||||||
if (!serverState.IsOpen)
|
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
|
||||||
|
|
||||||
//Instantiate the business object handler
|
|
||||||
WorkOrderTemplateBiz biz = WorkOrderTemplateBiz.GetBiz(ct, HttpContext);
|
|
||||||
|
|
||||||
var o = await biz.GetAsync(id, false);
|
|
||||||
if (o == null)
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
|
|
||||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//patch and validate
|
|
||||||
if (!await biz.PatchAsync(o, objectPatch, concurrencyToken))
|
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
|
||||||
}
|
|
||||||
catch (DbUpdateConcurrencyException)
|
|
||||||
{
|
|
||||||
if (!await biz.ExistsAsync(id))
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
else
|
|
||||||
return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT));
|
|
||||||
}
|
|
||||||
return Ok(ApiOkResponse.Response(new { ConcurrencyToken = o.ConcurrencyToken }, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Post WorkOrderTemplate
|
/// Post WorkOrderTemplate
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -159,37 +159,6 @@ namespace AyaNova.Biz
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//patch
|
|
||||||
internal async Task<bool> PatchAsync(Contract dbObj, JsonPatchDocument<Contract> objectPatch, uint concurrencyToken)
|
|
||||||
{
|
|
||||||
//Validate Patch is allowed
|
|
||||||
if (!ValidateJsonPatch<Contract>.Validate(this, objectPatch)) return false;
|
|
||||||
|
|
||||||
//make a snapshot of the original for validation but update the original to preserve workflow
|
|
||||||
Contract SnapshotOfOriginalDBObj = new Contract();
|
|
||||||
CopyObject.Copy(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
|
|
||||||
//Do the patching
|
|
||||||
objectPatch.ApplyTo(dbObj);
|
|
||||||
|
|
||||||
dbObj.Tags = TagUtil.NormalizeTags(dbObj.Tags);
|
|
||||||
dbObj.CustomFields = JsonUtil.CompactJson(dbObj.CustomFields);
|
|
||||||
|
|
||||||
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = concurrencyToken;
|
|
||||||
await ValidateAsync(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
if (HasErrors)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
//Log event and save context
|
|
||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
|
|
||||||
await SearchIndexAsync(dbObj, false);
|
|
||||||
|
|
||||||
await TagUtil.ProcessUpdateTagsInRepositoryAsync(ct, dbObj.Tags, SnapshotOfOriginalDBObj.Tags);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private async Task SearchIndexAsync(Contract obj, bool isNew)
|
private async Task SearchIndexAsync(Contract obj, bool isNew)
|
||||||
{
|
{
|
||||||
//SEARCH INDEXING
|
//SEARCH INDEXING
|
||||||
|
|||||||
@@ -159,37 +159,7 @@ namespace AyaNova.Biz
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//patch
|
|
||||||
internal async Task<bool> PatchAsync(Customer dbObj, JsonPatchDocument<Customer> objectPatch, uint concurrencyToken)
|
|
||||||
{
|
|
||||||
//Validate Patch is allowed
|
|
||||||
if (!ValidateJsonPatch<Customer>.Validate(this, objectPatch)) return false;
|
|
||||||
|
|
||||||
//make a snapshot of the original for validation but update the original to preserve workflow
|
|
||||||
Customer SnapshotOfOriginalDBObj = new Customer();
|
|
||||||
CopyObject.Copy(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
|
|
||||||
//Do the patching
|
|
||||||
objectPatch.ApplyTo(dbObj);
|
|
||||||
|
|
||||||
dbObj.Tags = TagUtil.NormalizeTags(dbObj.Tags);
|
|
||||||
dbObj.CustomFields = JsonUtil.CompactJson(dbObj.CustomFields);
|
|
||||||
|
|
||||||
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = concurrencyToken;
|
|
||||||
await ValidateAsync(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
if (HasErrors)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
//Log event and save context
|
|
||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
|
|
||||||
await SearchIndexAsync(dbObj, false);
|
|
||||||
|
|
||||||
await TagUtil.ProcessUpdateTagsInRepositoryAsync(ct, dbObj.Tags, SnapshotOfOriginalDBObj.Tags);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private async Task SearchIndexAsync(Customer obj, bool isNew)
|
private async Task SearchIndexAsync(Customer obj, bool isNew)
|
||||||
{
|
{
|
||||||
//SEARCH INDEXING
|
//SEARCH INDEXING
|
||||||
|
|||||||
@@ -158,38 +158,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//patch
|
|
||||||
internal async Task<bool> PatchAsync(HeadOffice dbObj, JsonPatchDocument<HeadOffice> objectPatch, uint concurrencyToken)
|
|
||||||
{
|
|
||||||
//Validate Patch is allowed
|
|
||||||
if (!ValidateJsonPatch<HeadOffice>.Validate(this, objectPatch)) return false;
|
|
||||||
|
|
||||||
//make a snapshot of the original for validation but update the original to preserve workflow
|
|
||||||
HeadOffice SnapshotOfOriginalDBObj = new HeadOffice();
|
|
||||||
CopyObject.Copy(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
|
|
||||||
//Do the patching
|
|
||||||
objectPatch.ApplyTo(dbObj);
|
|
||||||
|
|
||||||
dbObj.Tags = TagUtil.NormalizeTags(dbObj.Tags);
|
|
||||||
dbObj.CustomFields = JsonUtil.CompactJson(dbObj.CustomFields);
|
|
||||||
|
|
||||||
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = concurrencyToken;
|
|
||||||
await ValidateAsync(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
if (HasErrors)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
//Log event and save context
|
|
||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
|
|
||||||
await SearchIndexAsync(dbObj, false);
|
|
||||||
|
|
||||||
await TagUtil.ProcessUpdateTagsInRepositoryAsync(ct, dbObj.Tags, SnapshotOfOriginalDBObj.Tags);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private async Task SearchIndexAsync(HeadOffice obj, bool isNew)
|
private async Task SearchIndexAsync(HeadOffice obj, bool isNew)
|
||||||
{
|
{
|
||||||
//SEARCH INDEXING
|
//SEARCH INDEXING
|
||||||
|
|||||||
@@ -159,37 +159,6 @@ namespace AyaNova.Biz
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//patch
|
|
||||||
internal async Task<bool> PatchAsync(LoanUnit dbObj, JsonPatchDocument<LoanUnit> objectPatch, uint concurrencyToken)
|
|
||||||
{
|
|
||||||
//Validate Patch is allowed
|
|
||||||
if (!ValidateJsonPatch<LoanUnit>.Validate(this, objectPatch)) return false;
|
|
||||||
|
|
||||||
//make a snapshot of the original for validation but update the original to preserve workflow
|
|
||||||
LoanUnit SnapshotOfOriginalDBObj = new LoanUnit();
|
|
||||||
CopyObject.Copy(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
|
|
||||||
//Do the patching
|
|
||||||
objectPatch.ApplyTo(dbObj);
|
|
||||||
|
|
||||||
dbObj.Tags = TagUtil.NormalizeTags(dbObj.Tags);
|
|
||||||
dbObj.CustomFields = JsonUtil.CompactJson(dbObj.CustomFields);
|
|
||||||
|
|
||||||
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = concurrencyToken;
|
|
||||||
await ValidateAsync(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
if (HasErrors)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
//Log event and save context
|
|
||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
|
|
||||||
await SearchIndexAsync(dbObj, false);
|
|
||||||
|
|
||||||
await TagUtil.ProcessUpdateTagsInRepositoryAsync(ct, dbObj.Tags, SnapshotOfOriginalDBObj.Tags);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private async Task SearchIndexAsync(LoanUnit obj, bool isNew)
|
private async Task SearchIndexAsync(LoanUnit obj, bool isNew)
|
||||||
{
|
{
|
||||||
//SEARCH INDEXING
|
//SEARCH INDEXING
|
||||||
|
|||||||
@@ -159,37 +159,6 @@ namespace AyaNova.Biz
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//patch
|
|
||||||
internal async Task<bool> PatchAsync(PMTemplate dbObj, JsonPatchDocument<PMTemplate> objectPatch, uint concurrencyToken)
|
|
||||||
{
|
|
||||||
//Validate Patch is allowed
|
|
||||||
if (!ValidateJsonPatch<PMTemplate>.Validate(this, objectPatch)) return false;
|
|
||||||
|
|
||||||
//make a snapshot of the original for validation but update the original to preserve workflow
|
|
||||||
PMTemplate SnapshotOfOriginalDBObj = new PMTemplate();
|
|
||||||
CopyObject.Copy(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
|
|
||||||
//Do the patching
|
|
||||||
objectPatch.ApplyTo(dbObj);
|
|
||||||
|
|
||||||
dbObj.Tags = TagUtil.NormalizeTags(dbObj.Tags);
|
|
||||||
dbObj.CustomFields = JsonUtil.CompactJson(dbObj.CustomFields);
|
|
||||||
|
|
||||||
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = concurrencyToken;
|
|
||||||
await ValidateAsync(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
if (HasErrors)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
//Log event and save context
|
|
||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
|
|
||||||
await SearchIndexAsync(dbObj, false);
|
|
||||||
|
|
||||||
await TagUtil.ProcessUpdateTagsInRepositoryAsync(ct, dbObj.Tags, SnapshotOfOriginalDBObj.Tags);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private async Task SearchIndexAsync(PMTemplate obj, bool isNew)
|
private async Task SearchIndexAsync(PMTemplate obj, bool isNew)
|
||||||
{
|
{
|
||||||
//SEARCH INDEXING
|
//SEARCH INDEXING
|
||||||
|
|||||||
@@ -159,37 +159,7 @@ namespace AyaNova.Biz
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//patch
|
|
||||||
internal async Task<bool> PatchAsync(Part dbObj, JsonPatchDocument<Part> objectPatch, uint concurrencyToken)
|
|
||||||
{
|
|
||||||
//Validate Patch is allowed
|
|
||||||
if (!ValidateJsonPatch<Part>.Validate(this, objectPatch)) return false;
|
|
||||||
|
|
||||||
//make a snapshot of the original for validation but update the original to preserve workflow
|
|
||||||
Part SnapshotOfOriginalDBObj = new Part();
|
|
||||||
CopyObject.Copy(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
|
|
||||||
//Do the patching
|
|
||||||
objectPatch.ApplyTo(dbObj);
|
|
||||||
|
|
||||||
dbObj.Tags = TagUtil.NormalizeTags(dbObj.Tags);
|
|
||||||
dbObj.CustomFields = JsonUtil.CompactJson(dbObj.CustomFields);
|
|
||||||
|
|
||||||
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = concurrencyToken;
|
|
||||||
await ValidateAsync(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
if (HasErrors)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
//Log event and save context
|
|
||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
|
|
||||||
await SearchIndexAsync(dbObj, false);
|
|
||||||
|
|
||||||
await TagUtil.ProcessUpdateTagsInRepositoryAsync(ct, dbObj.Tags, SnapshotOfOriginalDBObj.Tags);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private async Task SearchIndexAsync(Part obj, bool isNew)
|
private async Task SearchIndexAsync(Part obj, bool isNew)
|
||||||
{
|
{
|
||||||
//SEARCH INDEXING
|
//SEARCH INDEXING
|
||||||
|
|||||||
@@ -158,38 +158,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//patch
|
|
||||||
internal async Task<bool> PatchAsync(Project dbObj, JsonPatchDocument<Project> objectPatch, uint concurrencyToken)
|
|
||||||
{
|
|
||||||
//Validate Patch is allowed
|
|
||||||
if (!ValidateJsonPatch<Project>.Validate(this, objectPatch)) return false;
|
|
||||||
|
|
||||||
//make a snapshot of the original for validation but update the original to preserve workflow
|
|
||||||
Project SnapshotOfOriginalDBObj = new Project();
|
|
||||||
CopyObject.Copy(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
|
|
||||||
//Do the patching
|
|
||||||
objectPatch.ApplyTo(dbObj);
|
|
||||||
|
|
||||||
dbObj.Tags = TagUtil.NormalizeTags(dbObj.Tags);
|
|
||||||
dbObj.CustomFields = JsonUtil.CompactJson(dbObj.CustomFields);
|
|
||||||
|
|
||||||
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = concurrencyToken;
|
|
||||||
await ValidateAsync(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
if (HasErrors)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
//Log event and save context
|
|
||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
|
|
||||||
await SearchIndexAsync(dbObj, false);
|
|
||||||
|
|
||||||
await TagUtil.ProcessUpdateTagsInRepositoryAsync(ct, dbObj.Tags, SnapshotOfOriginalDBObj.Tags);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private async Task SearchIndexAsync(Project obj, bool isNew)
|
private async Task SearchIndexAsync(Project obj, bool isNew)
|
||||||
{
|
{
|
||||||
//SEARCH INDEXING
|
//SEARCH INDEXING
|
||||||
|
|||||||
@@ -158,38 +158,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//patch
|
|
||||||
internal async Task<bool> PatchAsync(PurchaseOrder dbObj, JsonPatchDocument<PurchaseOrder> objectPatch, uint concurrencyToken)
|
|
||||||
{
|
|
||||||
//Validate Patch is allowed
|
|
||||||
if (!ValidateJsonPatch<PurchaseOrder>.Validate(this, objectPatch)) return false;
|
|
||||||
|
|
||||||
//make a snapshot of the original for validation but update the original to preserve workflow
|
|
||||||
PurchaseOrder SnapshotOfOriginalDBObj = new PurchaseOrder();
|
|
||||||
CopyObject.Copy(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
|
|
||||||
//Do the patching
|
|
||||||
objectPatch.ApplyTo(dbObj);
|
|
||||||
|
|
||||||
dbObj.Tags = TagUtil.NormalizeTags(dbObj.Tags);
|
|
||||||
dbObj.CustomFields = JsonUtil.CompactJson(dbObj.CustomFields);
|
|
||||||
|
|
||||||
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = concurrencyToken;
|
|
||||||
await ValidateAsync(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
if (HasErrors)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
//Log event and save context
|
|
||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
|
|
||||||
await SearchIndexAsync(dbObj, false);
|
|
||||||
|
|
||||||
await TagUtil.ProcessUpdateTagsInRepositoryAsync(ct, dbObj.Tags, SnapshotOfOriginalDBObj.Tags);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private async Task SearchIndexAsync(PurchaseOrder obj, bool isNew)
|
private async Task SearchIndexAsync(PurchaseOrder obj, bool isNew)
|
||||||
{
|
{
|
||||||
//SEARCH INDEXING
|
//SEARCH INDEXING
|
||||||
|
|||||||
@@ -158,38 +158,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//patch
|
|
||||||
internal async Task<bool> PatchAsync(QuoteTemplate dbObj, JsonPatchDocument<QuoteTemplate> objectPatch, uint concurrencyToken)
|
|
||||||
{
|
|
||||||
//Validate Patch is allowed
|
|
||||||
if (!ValidateJsonPatch<QuoteTemplate>.Validate(this, objectPatch)) return false;
|
|
||||||
|
|
||||||
//make a snapshot of the original for validation but update the original to preserve workflow
|
|
||||||
QuoteTemplate SnapshotOfOriginalDBObj = new QuoteTemplate();
|
|
||||||
CopyObject.Copy(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
|
|
||||||
//Do the patching
|
|
||||||
objectPatch.ApplyTo(dbObj);
|
|
||||||
|
|
||||||
dbObj.Tags = TagUtil.NormalizeTags(dbObj.Tags);
|
|
||||||
dbObj.CustomFields = JsonUtil.CompactJson(dbObj.CustomFields);
|
|
||||||
|
|
||||||
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = concurrencyToken;
|
|
||||||
await ValidateAsync(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
if (HasErrors)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
//Log event and save context
|
|
||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
|
|
||||||
await SearchIndexAsync(dbObj, false);
|
|
||||||
|
|
||||||
await TagUtil.ProcessUpdateTagsInRepositoryAsync(ct, dbObj.Tags, SnapshotOfOriginalDBObj.Tags);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private async Task SearchIndexAsync(QuoteTemplate obj, bool isNew)
|
private async Task SearchIndexAsync(QuoteTemplate obj, bool isNew)
|
||||||
{
|
{
|
||||||
//SEARCH INDEXING
|
//SEARCH INDEXING
|
||||||
|
|||||||
@@ -159,37 +159,7 @@ namespace AyaNova.Biz
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//patch
|
|
||||||
internal async Task<bool> PatchAsync(Unit dbObj, JsonPatchDocument<Unit> objectPatch, uint concurrencyToken)
|
|
||||||
{
|
|
||||||
//Validate Patch is allowed
|
|
||||||
if (!ValidateJsonPatch<Unit>.Validate(this, objectPatch)) return false;
|
|
||||||
|
|
||||||
//make a snapshot of the original for validation but update the original to preserve workflow
|
|
||||||
Unit SnapshotOfOriginalDBObj = new Unit();
|
|
||||||
CopyObject.Copy(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
|
|
||||||
//Do the patching
|
|
||||||
objectPatch.ApplyTo(dbObj);
|
|
||||||
|
|
||||||
dbObj.Tags = TagUtil.NormalizeTags(dbObj.Tags);
|
|
||||||
dbObj.CustomFields = JsonUtil.CompactJson(dbObj.CustomFields);
|
|
||||||
|
|
||||||
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = concurrencyToken;
|
|
||||||
await ValidateAsync(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
if (HasErrors)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
//Log event and save context
|
|
||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
|
|
||||||
await SearchIndexAsync(dbObj, false);
|
|
||||||
|
|
||||||
await TagUtil.ProcessUpdateTagsInRepositoryAsync(ct, dbObj.Tags, SnapshotOfOriginalDBObj.Tags);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private async Task SearchIndexAsync(Unit obj, bool isNew)
|
private async Task SearchIndexAsync(Unit obj, bool isNew)
|
||||||
{
|
{
|
||||||
//SEARCH INDEXING
|
//SEARCH INDEXING
|
||||||
|
|||||||
@@ -158,38 +158,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//patch
|
|
||||||
internal async Task<bool> PatchAsync(UnitModel dbObj, JsonPatchDocument<UnitModel> objectPatch, uint concurrencyToken)
|
|
||||||
{
|
|
||||||
//Validate Patch is allowed
|
|
||||||
if (!ValidateJsonPatch<UnitModel>.Validate(this, objectPatch)) return false;
|
|
||||||
|
|
||||||
//make a snapshot of the original for validation but update the original to preserve workflow
|
|
||||||
UnitModel SnapshotOfOriginalDBObj = new UnitModel();
|
|
||||||
CopyObject.Copy(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
|
|
||||||
//Do the patching
|
|
||||||
objectPatch.ApplyTo(dbObj);
|
|
||||||
|
|
||||||
dbObj.Tags = TagUtil.NormalizeTags(dbObj.Tags);
|
|
||||||
dbObj.CustomFields = JsonUtil.CompactJson(dbObj.CustomFields);
|
|
||||||
|
|
||||||
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = concurrencyToken;
|
|
||||||
await ValidateAsync(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
if (HasErrors)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
//Log event and save context
|
|
||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
|
|
||||||
await SearchIndexAsync(dbObj, false);
|
|
||||||
|
|
||||||
await TagUtil.ProcessUpdateTagsInRepositoryAsync(ct, dbObj.Tags, SnapshotOfOriginalDBObj.Tags);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private async Task SearchIndexAsync(UnitModel obj, bool isNew)
|
private async Task SearchIndexAsync(UnitModel obj, bool isNew)
|
||||||
{
|
{
|
||||||
//SEARCH INDEXING
|
//SEARCH INDEXING
|
||||||
|
|||||||
@@ -193,58 +193,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//patch
|
|
||||||
internal async Task<bool> PatchAsync(User dbObj, JsonPatchDocument<User> objectPatch, uint concurrencyToken)
|
|
||||||
{
|
|
||||||
//Validate Patch is allowed
|
|
||||||
if (!ValidateJsonPatch<User>.Validate(this, objectPatch)) return false;
|
|
||||||
|
|
||||||
//make a snapshot of the original for validation but update the original to preserve workflow
|
|
||||||
User SnapshotOfOriginalDBObj = new User();
|
|
||||||
CopyObject.Copy(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
|
|
||||||
//Do the patching
|
|
||||||
objectPatch.ApplyTo(dbObj);
|
|
||||||
dbObj.Tags = TagUtil.NormalizeTags(dbObj.Tags);
|
|
||||||
dbObj.CustomFields = JsonUtil.CompactJson(dbObj.CustomFields);
|
|
||||||
|
|
||||||
//Is the user patching the password?
|
|
||||||
if (!string.IsNullOrWhiteSpace(dbObj.Password) && dbObj.Password != SnapshotOfOriginalDBObj.Password)
|
|
||||||
{
|
|
||||||
//YES password is being updated:
|
|
||||||
dbObj.Password = Hasher.hash(dbObj.Salt, dbObj.Password);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Updating login?
|
|
||||||
if (!string.IsNullOrWhiteSpace(dbObj.Login) && dbObj.Login != SnapshotOfOriginalDBObj.Login)
|
|
||||||
{
|
|
||||||
//YES Login is being updated:
|
|
||||||
dbObj.Login = SnapshotOfOriginalDBObj.Login;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//No, use the original value
|
|
||||||
dbObj.Login = SnapshotOfOriginalDBObj.Login;
|
|
||||||
}
|
|
||||||
|
|
||||||
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = concurrencyToken;
|
|
||||||
await ValidateAsync(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
if (HasErrors)
|
|
||||||
return false;
|
|
||||||
await ct.SaveChangesAsync();
|
|
||||||
|
|
||||||
//Log modification and save context
|
|
||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
|
|
||||||
await SearchIndexAsync(dbObj, false);
|
|
||||||
|
|
||||||
await TagUtil.ProcessUpdateTagsInRepositoryAsync(ct, dbObj.Tags, SnapshotOfOriginalDBObj.Tags);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//put
|
//put
|
||||||
internal async Task<bool> ChangePasswordAsync(long userId, string newPassword)
|
internal async Task<bool> ChangePasswordAsync(long userId, string newPassword)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -62,29 +62,7 @@ namespace AyaNova.Biz
|
|||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObj.Id, AyaType.User, AyaEvent.Modified), ct);
|
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObj.Id, AyaType.User, AyaEvent.Modified), ct);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//patch
|
|
||||||
internal async Task<bool> PatchAsync(UserOptions dbObj, JsonPatchDocument<UserOptions> objectPatch, uint concurrencyToken)
|
|
||||||
{
|
|
||||||
//Validate Patch is allowed
|
|
||||||
if (!ValidateJsonPatch<UserOptions>.Validate(this, objectPatch, "UserId")) return false;
|
|
||||||
|
|
||||||
//Do the patching
|
|
||||||
objectPatch.ApplyTo(dbObj);
|
|
||||||
|
|
||||||
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = concurrencyToken;
|
|
||||||
Validate(dbObj);
|
|
||||||
if (HasErrors)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
await ct.SaveChangesAsync();
|
|
||||||
//Log
|
|
||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObj.Id, AyaType.User, AyaEvent.Modified), ct);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//VALIDATION
|
//VALIDATION
|
||||||
|
|||||||
@@ -158,38 +158,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//patch
|
|
||||||
internal async Task<bool> PatchAsync(Vendor dbObj, JsonPatchDocument<Vendor> objectPatch, uint concurrencyToken)
|
|
||||||
{
|
|
||||||
//Validate Patch is allowed
|
|
||||||
if (!ValidateJsonPatch<Vendor>.Validate(this, objectPatch)) return false;
|
|
||||||
|
|
||||||
//make a snapshot of the original for validation but update the original to preserve workflow
|
|
||||||
Vendor SnapshotOfOriginalDBObj = new Vendor();
|
|
||||||
CopyObject.Copy(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
|
|
||||||
//Do the patching
|
|
||||||
objectPatch.ApplyTo(dbObj);
|
|
||||||
|
|
||||||
dbObj.Tags = TagUtil.NormalizeTags(dbObj.Tags);
|
|
||||||
dbObj.CustomFields = JsonUtil.CompactJson(dbObj.CustomFields);
|
|
||||||
|
|
||||||
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = concurrencyToken;
|
|
||||||
await ValidateAsync(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
if (HasErrors)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
//Log event and save context
|
|
||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
|
|
||||||
await SearchIndexAsync(dbObj, false);
|
|
||||||
|
|
||||||
await TagUtil.ProcessUpdateTagsInRepositoryAsync(ct, dbObj.Tags, SnapshotOfOriginalDBObj.Tags);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private async Task SearchIndexAsync(Vendor obj, bool isNew)
|
private async Task SearchIndexAsync(Vendor obj, bool isNew)
|
||||||
{
|
{
|
||||||
//SEARCH INDEXING
|
//SEARCH INDEXING
|
||||||
|
|||||||
@@ -158,37 +158,6 @@ namespace AyaNova.Biz
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//patch
|
|
||||||
internal async Task<bool> PatchAsync(Widget dbObj, JsonPatchDocument<Widget> objectPatch, uint concurrencyToken)
|
|
||||||
{
|
|
||||||
//Validate Patch is allowed
|
|
||||||
//Note: Id and Serial are all checked for and disallowed in the validate code by default
|
|
||||||
if (!ValidateJsonPatch<Widget>.Validate(this, objectPatch)) return false;
|
|
||||||
|
|
||||||
//make a snapshot of the original for validation but update the original to preserve workflow
|
|
||||||
Widget SnapshotOfOriginalDBObj = new Widget();
|
|
||||||
CopyObject.Copy(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
|
|
||||||
//Do the patching
|
|
||||||
objectPatch.ApplyTo(dbObj);
|
|
||||||
|
|
||||||
dbObj.Tags = TagUtil.NormalizeTags(dbObj.Tags);
|
|
||||||
dbObj.CustomFields = JsonUtil.CompactJson(dbObj.CustomFields);
|
|
||||||
|
|
||||||
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = concurrencyToken;
|
|
||||||
await ValidateAsync(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
if (HasErrors)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
//Log event and save context
|
|
||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
|
|
||||||
await SearchIndexAsync(dbObj, false);
|
|
||||||
|
|
||||||
await TagUtil.ProcessUpdateTagsInRepositoryAsync(ct, dbObj.Tags, SnapshotOfOriginalDBObj.Tags);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private async Task SearchIndexAsync(Widget obj, bool isNew)
|
private async Task SearchIndexAsync(Widget obj, bool isNew)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -159,37 +159,7 @@ namespace AyaNova.Biz
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//patch
|
|
||||||
internal async Task<bool> PatchAsync(WorkOrderTemplate dbObj, JsonPatchDocument<WorkOrderTemplate> objectPatch, uint concurrencyToken)
|
|
||||||
{
|
|
||||||
//Validate Patch is allowed
|
|
||||||
if (!ValidateJsonPatch<WorkOrderTemplate>.Validate(this, objectPatch)) return false;
|
|
||||||
|
|
||||||
//make a snapshot of the original for validation but update the original to preserve workflow
|
|
||||||
WorkOrderTemplate SnapshotOfOriginalDBObj = new WorkOrderTemplate();
|
|
||||||
CopyObject.Copy(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
|
|
||||||
//Do the patching
|
|
||||||
objectPatch.ApplyTo(dbObj);
|
|
||||||
|
|
||||||
dbObj.Tags = TagUtil.NormalizeTags(dbObj.Tags);
|
|
||||||
dbObj.CustomFields = JsonUtil.CompactJson(dbObj.CustomFields);
|
|
||||||
|
|
||||||
ct.Entry(dbObj).OriginalValues["ConcurrencyToken"] = concurrencyToken;
|
|
||||||
await ValidateAsync(dbObj, SnapshotOfOriginalDBObj);
|
|
||||||
if (HasErrors)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
//Log event and save context
|
|
||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
|
|
||||||
await SearchIndexAsync(dbObj, false);
|
|
||||||
|
|
||||||
await TagUtil.ProcessUpdateTagsInRepositoryAsync(ct, dbObj.Tags, SnapshotOfOriginalDBObj.Tags);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private async Task SearchIndexAsync(WorkOrderTemplate obj, bool isNew)
|
private async Task SearchIndexAsync(WorkOrderTemplate obj, bool isNew)
|
||||||
{
|
{
|
||||||
//SEARCH INDEXING
|
//SEARCH INDEXING
|
||||||
|
|||||||
Reference in New Issue
Block a user