This commit is contained in:
@@ -7,6 +7,7 @@ using Microsoft.Extensions.Logging;
|
||||
using AyaNova.Models;
|
||||
using AyaNova.Api.ControllerHelpers;
|
||||
using AyaNova.Biz;
|
||||
using System;
|
||||
|
||||
|
||||
namespace AyaNova.Api.Controllers
|
||||
@@ -66,10 +67,10 @@ namespace AyaNova.Api.Controllers
|
||||
/// <summary>
|
||||
/// Get Integration
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="integrationAppId"></param>
|
||||
/// <returns>Integration</returns>
|
||||
[HttpGet("{id}")]
|
||||
public async Task<IActionResult> GetIntegration([FromRoute] long id)
|
||||
[HttpGet("{integrationAppId}")]
|
||||
public async Task<IActionResult> GetIntegration([FromRoute] Guid integrationAppId)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
@@ -78,7 +79,7 @@ namespace AyaNova.Api.Controllers
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
if (!ModelState.IsValid)
|
||||
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));
|
||||
return Ok(ApiOkResponse.Response(o));
|
||||
}
|
||||
@@ -112,10 +113,10 @@ namespace AyaNova.Api.Controllers
|
||||
/// <summary>
|
||||
/// Delete Integration
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="integrationAppId"></param>
|
||||
/// <returns>NoContent</returns>
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> DeleteIntegration([FromRoute] long id)
|
||||
[HttpDelete("{integrationAppId}")]
|
||||
public async Task<IActionResult> DeleteIntegration([FromRoute] Guid integrationAppId)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
@@ -124,7 +125,7 @@ namespace AyaNova.Api.Controllers
|
||||
IntegrationBiz biz = IntegrationBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasDeleteRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
if (!await biz.DeleteAsync(id))
|
||||
if (!await biz.DeleteAsync(integrationAppId))
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
@@ -61,11 +61,11 @@ namespace AyaNova.Biz
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//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)
|
||||
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;
|
||||
}
|
||||
@@ -77,10 +77,10 @@ namespace AyaNova.Biz
|
||||
internal async Task<Integration> PutAsync(Integration putObject)
|
||||
{
|
||||
//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)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND, "id");
|
||||
AddError(ApiErrorCode.NOT_FOUND, "IntegrationAppId");
|
||||
return null;
|
||||
}
|
||||
if (dbObject.Concurrency != putObject.Concurrency)
|
||||
@@ -114,11 +114,11 @@ namespace AyaNova.Biz
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//DELETE
|
||||
//
|
||||
internal async Task<bool> DeleteAsync(long id)
|
||||
internal async Task<bool> DeleteAsync(Guid IntegrationAppId)
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
Integration dbObject = await GetAsync(id, false);
|
||||
Integration dbObject = await GetAsync(IntegrationAppId, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
|
||||
Reference in New Issue
Block a user