diff --git a/server/AyaNova/Controllers/IntegrationController.cs b/server/AyaNova/Controllers/IntegrationController.cs index ac0f9a90..788d7301 100644 --- a/server/AyaNova/Controllers/IntegrationController.cs +++ b/server/AyaNova/Controllers/IntegrationController.cs @@ -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 /// /// Get Integration /// - /// + /// /// Integration - [HttpGet("{id}")] - public async Task GetIntegration([FromRoute] long id) + [HttpGet("{integrationAppId}")] + public async Task 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 /// /// Delete Integration /// - /// + /// /// NoContent - [HttpDelete("{id}")] - public async Task DeleteIntegration([FromRoute] long id) + [HttpDelete("{integrationAppId}")] + public async Task 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(); } diff --git a/server/AyaNova/biz/IntegrationBiz.cs b/server/AyaNova/biz/IntegrationBiz.cs index 1f8bd9f0..aa580d6f 100644 --- a/server/AyaNova/biz/IntegrationBiz.cs +++ b/server/AyaNova/biz/IntegrationBiz.cs @@ -61,11 +61,11 @@ namespace AyaNova.Biz //////////////////////////////////////////////////////////////////////////////////////////////// //GET // - internal async Task GetAsync(long id, bool logTheGetEvent = true, bool populatePartNames = false) + internal async Task 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 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 DeleteAsync(long id) + internal async Task 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);