This commit is contained in:
@@ -7,6 +7,7 @@ using Microsoft.Extensions.Logging;
|
|||||||
using AyaNova.Models;
|
using AyaNova.Models;
|
||||||
using AyaNova.Api.ControllerHelpers;
|
using AyaNova.Api.ControllerHelpers;
|
||||||
using AyaNova.Biz;
|
using AyaNova.Biz;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
namespace AyaNova.Api.Controllers
|
namespace AyaNova.Api.Controllers
|
||||||
@@ -66,10 +67,10 @@ namespace AyaNova.Api.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get Integration
|
/// Get Integration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="integrationAppId"></param>
|
||||||
/// <returns>Integration</returns>
|
/// <returns>Integration</returns>
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{integrationAppId}")]
|
||||||
public async Task<IActionResult> GetIntegration([FromRoute] long id)
|
public async Task<IActionResult> GetIntegration([FromRoute] Guid integrationAppId)
|
||||||
{
|
{
|
||||||
if (!serverState.IsOpen)
|
if (!serverState.IsOpen)
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
@@ -78,7 +79,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
var o = await biz.GetAsync(id, true, true);
|
var o = await biz.GetAsync(integrationAppId, true, true);
|
||||||
if (o == null) return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
if (o == null) return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||||
return Ok(ApiOkResponse.Response(o));
|
return Ok(ApiOkResponse.Response(o));
|
||||||
}
|
}
|
||||||
@@ -112,10 +113,10 @@ namespace AyaNova.Api.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delete Integration
|
/// Delete Integration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="integrationAppId"></param>
|
||||||
/// <returns>NoContent</returns>
|
/// <returns>NoContent</returns>
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{integrationAppId}")]
|
||||||
public async Task<IActionResult> DeleteIntegration([FromRoute] long id)
|
public async Task<IActionResult> DeleteIntegration([FromRoute] Guid integrationAppId)
|
||||||
{
|
{
|
||||||
if (!serverState.IsOpen)
|
if (!serverState.IsOpen)
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
@@ -124,7 +125,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
IntegrationBiz biz = IntegrationBiz.GetBiz(ct, HttpContext);
|
IntegrationBiz biz = IntegrationBiz.GetBiz(ct, HttpContext);
|
||||||
if (!Authorized.HasDeleteRole(HttpContext.Items, biz.BizType))
|
if (!Authorized.HasDeleteRole(HttpContext.Items, biz.BizType))
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
if (!await biz.DeleteAsync(id))
|
if (!await biz.DeleteAsync(integrationAppId))
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,11 +61,11 @@ namespace AyaNova.Biz
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//GET
|
//GET
|
||||||
//
|
//
|
||||||
internal async Task<Integration> GetAsync(long id, bool logTheGetEvent = true, bool populatePartNames = false)
|
internal async Task<Integration> GetAsync(Guid IntegrationAppId, bool logTheGetEvent = true, bool populatePartNames = false)
|
||||||
{
|
{
|
||||||
var ret = await ct.Integration.AsNoTracking().Include(z => z.Items).SingleOrDefaultAsync(m => m.Id == id);
|
var ret = await ct.Integration.AsNoTracking().Include(z => z.Items).SingleOrDefaultAsync(m => m.IntegrationAppId == IntegrationAppId);
|
||||||
if (logTheGetEvent && ret != null)
|
if (logTheGetEvent && ret != null)
|
||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, id, BizType, AyaEvent.Retrieved), ct);
|
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, ret.Id, BizType, AyaEvent.Retrieved), ct);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -77,10 +77,10 @@ namespace AyaNova.Biz
|
|||||||
internal async Task<Integration> PutAsync(Integration putObject)
|
internal async Task<Integration> PutAsync(Integration putObject)
|
||||||
{
|
{
|
||||||
//Get the db object with no tracking as about to be replaced not updated
|
//Get the db object with no tracking as about to be replaced not updated
|
||||||
Integration dbObject = await GetAsync(putObject.Id, false);
|
Integration dbObject = await GetAsync(putObject.IntegrationAppId, false);
|
||||||
if (dbObject == null)
|
if (dbObject == null)
|
||||||
{
|
{
|
||||||
AddError(ApiErrorCode.NOT_FOUND, "id");
|
AddError(ApiErrorCode.NOT_FOUND, "IntegrationAppId");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (dbObject.Concurrency != putObject.Concurrency)
|
if (dbObject.Concurrency != putObject.Concurrency)
|
||||||
@@ -114,11 +114,11 @@ namespace AyaNova.Biz
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//DELETE
|
//DELETE
|
||||||
//
|
//
|
||||||
internal async Task<bool> DeleteAsync(long id)
|
internal async Task<bool> DeleteAsync(Guid IntegrationAppId)
|
||||||
{
|
{
|
||||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||||
{
|
{
|
||||||
Integration dbObject = await GetAsync(id, false);
|
Integration dbObject = await GetAsync(IntegrationAppId, false);
|
||||||
if (dbObject == null)
|
if (dbObject == null)
|
||||||
{
|
{
|
||||||
AddError(ApiErrorCode.NOT_FOUND);
|
AddError(ApiErrorCode.NOT_FOUND);
|
||||||
|
|||||||
Reference in New Issue
Block a user