From 85aab7269271d67391b60ca95a71d65f740d71a0 Mon Sep 17 00:00:00 2001 From: MiraGeowerkstatt Date: Tue, 1 Oct 2024 17:27:47 +0200 Subject: [PATCH 1/7] Add put method to borehole controller --- src/api/Controllers/BoreholeController.cs | 113 ++++++++++---- tests/Controllers/BoreholeControllerTest.cs | 158 +++++++++++++++++++- 2 files changed, 243 insertions(+), 28 deletions(-) diff --git a/src/api/Controllers/BoreholeController.cs b/src/api/Controllers/BoreholeController.cs index dcc31acab..698446b9c 100644 --- a/src/api/Controllers/BoreholeController.cs +++ b/src/api/Controllers/BoreholeController.cs @@ -9,42 +9,70 @@ namespace BDMS.Controllers; [ApiController] [Route("api/v{version:apiVersion}/[controller]")] -public class BoreholeController : ControllerBase +public class BoreholeController : BoreholeControllerBase { - private readonly BdmsContext context; - private readonly ILogger logger; + public BoreholeController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) + : base(context, logger, boreholeLockService) + { + } - public BoreholeController(BdmsContext context, ILogger logger) + /// + [Authorize(Policy = PolicyNames.Viewer)] + public async override Task> EditAsync(Borehole entity) { - this.context = context; - this.logger = logger; + if (entity == null) + { + return BadRequest(ModelState); + } + + var existingBorehole = await Context.Boreholes + .SingleOrDefaultAsync(l => l.Id == entity.Id) + .ConfigureAwait(false); + + if (existingBorehole == null) + { + return NotFound(); + } + + Context.Entry(existingBorehole).CurrentValues.SetValues(entity); + + try + { + await Context.UpdateChangeInformationAndSaveChangesAsync(HttpContext).ConfigureAwait(false); + return await GetByIdAsync(entity.Id).ConfigureAwait(false); + } + catch (Exception ex) + { + var errorMessage = "An error occurred while saving the entity changes."; + Logger?.LogError(ex, errorMessage); + return Problem(errorMessage); + } } /// - /// Asynchronously copies a . + /// Asynchronously gets the with the specified . /// - /// The of the borehole to copy. - /// The of the new . - /// The id of the newly created . - [HttpPost("copy")] + /// The id of borehole to get. + [HttpGet("{id}")] [Authorize(Policy = PolicyNames.Viewer)] - public async Task> CopyAsync([Required] int id, [Required] int workgroupId) + public async Task> GetByIdAsync(int id) { - logger.LogInformation("Copy borehole with id <{BoreholeId}> to workgroup with id <{WorkgroupId}>", id, workgroupId); - - var user = await context.Users - .Include(u => u.WorkgroupRoles) + var borehole = await GetBoreholesWithIncludes() .AsNoTracking() - .SingleOrDefaultAsync(u => u.SubjectId == HttpContext.GetUserSubjectId()) + .SingleOrDefaultAsync(l => l.Id == id) .ConfigureAwait(false); - if (user == null || user.WorkgroupRoles == null || !user.WorkgroupRoles.Any(w => w.WorkgroupId == workgroupId && w.Role == Role.Editor)) + if (borehole == null) { - return Unauthorized(); + return NotFound(); } - var borehole = await context.Boreholes - .Include(b => b.Stratigraphies).ThenInclude(s => s.Layers).ThenInclude(l => l.LayerColorCodes) + return Ok(borehole); + } + + private IQueryable GetBoreholesWithIncludes() + { + return Context.Boreholes.Include(b => b.Stratigraphies).ThenInclude(s => s.Layers).ThenInclude(l => l.LayerColorCodes) .Include(b => b.Stratigraphies).ThenInclude(s => s.Layers).ThenInclude(l => l.LayerDebrisCodes) .Include(b => b.Stratigraphies).ThenInclude(s => s.Layers).ThenInclude(l => l.LayerGrainAngularityCodes) .Include(b => b.Stratigraphies).ThenInclude(s => s.Layers).ThenInclude(l => l.LayerGrainShapeCodes) @@ -62,7 +90,33 @@ public async Task> CopyAsync([Required] int id, [Required] int .Include(b => b.BoreholeCodelists) .Include(b => b.Workflows) .Include(b => b.BoreholeFiles) - .Include(b => b.BoreholeGeometry) + .Include(b => b.BoreholeGeometry); + } + + /// + /// Asynchronously copies a . + /// + /// The of the borehole to copy. + /// The of the new . + /// The id of the newly created . + [HttpPost("copy")] + [Authorize(Policy = PolicyNames.Viewer)] + public async Task> CopyAsync([Required] int id, [Required] int workgroupId) + { + Logger.LogInformation("Copy borehole with id <{BoreholeId}> to workgroup with id <{WorkgroupId}>", id, workgroupId); + + var user = await Context.Users + .Include(u => u.WorkgroupRoles) + .AsNoTracking() + .SingleOrDefaultAsync(u => u.SubjectId == HttpContext.GetUserSubjectId()) + .ConfigureAwait(false); + + if (user == null || user.WorkgroupRoles == null || !user.WorkgroupRoles.Any(w => w.WorkgroupId == workgroupId && w.Role == Role.Editor)) + { + return Unauthorized(); + } + + var borehole = await GetBoreholesWithIncludes() .AsNoTracking() .SingleOrDefaultAsync(b => b.Id == id) .ConfigureAwait(false); @@ -79,7 +133,7 @@ public async Task> CopyAsync([Required] int id, [Required] int // if there are no fieldMeasurementResults of hydrotestResults the LoadAsync method will be called but have no effect foreach (var fieldMeasurement in fieldMeasurements) { - await context.Entry(fieldMeasurement) + await Context.Entry(fieldMeasurement) .Collection(f => f.FieldMeasurementResults) .LoadAsync() .ConfigureAwait(false); @@ -88,7 +142,7 @@ await context.Entry(fieldMeasurement) var hydrotests = borehole.Observations.OfType().ToList(); foreach (var hydrotest in hydrotests) { - await context.Entry(hydrotest) + await Context.Entry(hydrotest) .Collection(h => h.HydrotestResults) .LoadAsync() .ConfigureAwait(false); @@ -207,9 +261,16 @@ await context.Entry(hydrotest) borehole.OriginalName += " (Copy)"; - var entityEntry = await context.AddAsync(borehole).ConfigureAwait(false); - await context.SaveChangesAsync().ConfigureAwait(false); + var entityEntry = await Context.AddAsync(borehole).ConfigureAwait(false); + await Context.SaveChangesAsync().ConfigureAwait(false); return Ok(entityEntry.Entity.Id); } + + /// + protected override async Task GetBoreholeId(Borehole entity) + { + if (entity == null) return default; + return await Task.FromResult(entity.Id).ConfigureAwait(false); + } } diff --git a/tests/Controllers/BoreholeControllerTest.cs b/tests/Controllers/BoreholeControllerTest.cs index 6a5ab18ee..35390076c 100644 --- a/tests/Controllers/BoreholeControllerTest.cs +++ b/tests/Controllers/BoreholeControllerTest.cs @@ -5,6 +5,7 @@ using Microsoft.Extensions.Logging; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; + using static BDMS.Helpers; namespace BDMS.Controllers; @@ -22,13 +23,166 @@ public class BoreholeControllerTest public void TestInitialize() { context = ContextFactory.GetTestContext(); - controller = new BoreholeController(context, new Mock>().Object) { ControllerContext = GetControllerContextAdmin() }; + var boreholeLockServiceMock = new Mock(MockBehavior.Strict); + boreholeLockServiceMock + .Setup(x => x.IsBoreholeLockedAsync(It.IsAny(), It.IsAny())) + .ReturnsAsync(false); + controller = new BoreholeController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; + boreholeId = GetBoreholeIdToCopy(); } [TestCleanup] public async Task TestCleanup() => await context.DisposeAsync(); + [TestMethod] + public async Task EditBoreholeWithCompleteBorehole() + { + var id = 1_000_257; + + var newBorehole = new Borehole + { + Id = id, + CreatedById = 4, + UpdatedById = 4, + Locked = null, + LockedById = null, + WorkgroupId = 1, + IsPublic = true, + TypeId = 20101003, + LocationX = 2600000.0, + PrecisionLocationX = 5, + LocationY = 1200000.0, + PrecisionLocationY = 5, + LocationXLV03 = 600000.0, + PrecisionLocationXLV03 = 5, + LocationYLV03 = 200000.0, + PrecisionLocationYLV03 = 5, + OriginalReferenceSystem = ReferenceSystem.LV95, + ElevationZ = 450.5, + HrsId = 20106001, + TotalDepth = 100.0, + RestrictionId = 20111003, + RestrictionUntil = DateTime.UtcNow.AddYears(1), + NationalInterest = false, + OriginalName = "BH-257", + AlternateName = "Borehole 257", + LocationPrecisionId = 20113002, + ElevationPrecisionId = null, + ProjectName = "Project Alpha", + Country = "CH", + Canton = "ZH", + Municipality = "Zurich", + PurposeId = 22103002, + StatusId = 22104001, + QtDepthId = 22108005, + TopBedrockFreshMd = 10.5, + TopBedrockWeatheredMd = 8.0, + HasGroundwater = true, + Geometry = null, + Remarks = "Test borehole for project", + LithologyTopBedrockId = 15104934, + LithostratigraphyId = 15300259, + ChronostratigraphyId = 15001141, + ReferenceElevation = 500.0, + QtReferenceElevationId = 20114002, + ReferenceElevationTypeId = 20117003, + }; + + var boreholeToEdit = context.Boreholes.Single(c => c.Id == id); + Assert.AreEqual(1, boreholeToEdit.Stratigraphies.Count); + Assert.AreEqual(0, boreholeToEdit.Workflows.Count); + + Assert.AreEqual(2, boreholeToEdit.CreatedById); + Assert.AreEqual(5, boreholeToEdit.UpdatedById); + + // Update Borehole + var response = await controller.EditAsync(newBorehole); + ActionResultAssert.IsOk(response.Result); + + // Assert Updates and unchanged values + var updatedBorehole = ActionResultAssert.IsOkObjectResult(response.Result); + + Assert.AreEqual(4, updatedBorehole.CreatedById); + Assert.AreEqual(1, updatedBorehole.UpdatedById); // updatedById should be overwritten by the test user id. + Assert.AreEqual(newBorehole.WorkgroupId, updatedBorehole.WorkgroupId); + Assert.AreEqual(newBorehole.IsPublic, updatedBorehole.IsPublic); + Assert.AreEqual(newBorehole.TypeId, updatedBorehole.TypeId); + Assert.AreEqual(newBorehole.LocationX, updatedBorehole.LocationX); + Assert.AreEqual(newBorehole.PrecisionLocationX, updatedBorehole.PrecisionLocationX); + Assert.AreEqual(newBorehole.LocationY, updatedBorehole.LocationY); + Assert.AreEqual(newBorehole.PrecisionLocationY, updatedBorehole.PrecisionLocationY); + Assert.AreEqual(newBorehole.LocationXLV03, updatedBorehole.LocationXLV03); + Assert.AreEqual(newBorehole.PrecisionLocationXLV03, updatedBorehole.PrecisionLocationXLV03); + Assert.AreEqual(newBorehole.LocationYLV03, updatedBorehole.LocationYLV03); + Assert.AreEqual(newBorehole.PrecisionLocationYLV03, updatedBorehole.PrecisionLocationYLV03); + Assert.AreEqual(newBorehole.ElevationZ, updatedBorehole.ElevationZ); + Assert.AreEqual(newBorehole.HrsId, updatedBorehole.HrsId); + Assert.AreEqual(newBorehole.TotalDepth, updatedBorehole.TotalDepth); + Assert.AreEqual(newBorehole.RestrictionId, updatedBorehole.RestrictionId); + Assert.AreEqual(newBorehole.RestrictionUntil.ToString(), updatedBorehole.RestrictionUntil.ToString()); + Assert.AreEqual(newBorehole.NationalInterest, updatedBorehole.NationalInterest); + Assert.AreEqual(newBorehole.OriginalName, updatedBorehole.OriginalName); + Assert.AreEqual(newBorehole.AlternateName, updatedBorehole.AlternateName); + Assert.AreEqual(newBorehole.LocationPrecisionId, updatedBorehole.LocationPrecisionId); + Assert.AreEqual(newBorehole.ElevationPrecisionId, updatedBorehole.ElevationPrecisionId); + Assert.AreEqual(newBorehole.ProjectName, updatedBorehole.ProjectName); + Assert.AreEqual(newBorehole.Country, updatedBorehole.Country); + Assert.AreEqual(newBorehole.Canton, updatedBorehole.Canton); + Assert.AreEqual(newBorehole.Municipality, updatedBorehole.Municipality); + Assert.AreEqual(newBorehole.PurposeId, updatedBorehole.PurposeId); + Assert.AreEqual(newBorehole.StatusId, updatedBorehole.StatusId); + Assert.AreEqual(newBorehole.QtDepthId, updatedBorehole.QtDepthId); + Assert.AreEqual(newBorehole.TopBedrockFreshMd, updatedBorehole.TopBedrockFreshMd); + Assert.AreEqual(newBorehole.TopBedrockWeatheredMd, updatedBorehole.TopBedrockWeatheredMd); + Assert.AreEqual(newBorehole.HasGroundwater, updatedBorehole.HasGroundwater); + Assert.AreEqual(newBorehole.Remarks, updatedBorehole.Remarks); + Assert.AreEqual(newBorehole.LithologyTopBedrockId, updatedBorehole.LithologyTopBedrockId); + Assert.AreEqual(newBorehole.LithostratigraphyId, updatedBorehole.LithostratigraphyId); + Assert.AreEqual(newBorehole.ChronostratigraphyId, updatedBorehole.ChronostratigraphyId); + Assert.AreEqual(newBorehole.ReferenceElevation, updatedBorehole.ReferenceElevation); + Assert.AreEqual(newBorehole.QtReferenceElevationId, updatedBorehole.QtReferenceElevationId); + Assert.AreEqual(newBorehole.ReferenceElevationTypeId, updatedBorehole.ReferenceElevationTypeId); + + // Stratigraphies and workflows remain unchanged + Assert.AreEqual(1, updatedBorehole.Stratigraphies.Count); + Assert.AreEqual(0, updatedBorehole.Workflows.Count); + } + + [TestMethod] + public async Task EditWithInexistentIdReturnsNotFound() + { + var id = 9111794; + var borehole = new Borehole + { + Id = id, + }; + + // Upate Borehole + var response = await controller.EditAsync(borehole); + ActionResultAssert.IsNotFound(response.Result); + } + + [TestMethod] + public async Task EditWithoutBoreholeReturnsBadRequest() + { + var response = await controller.EditAsync(null); + ActionResultAssert.IsBadRequest(response.Result); + } + + [TestMethod] + public async Task EditWithWrongCodelistCodesReturnsBadRequest() + { + var borehole = new Borehole + { + Id = 1_000_256, + PurposeId = 99999, // Id violating constraint + }; + + var response = await controller.EditAsync(borehole); + ActionResultAssert.IsInternalServerError(response.Result); + } + [TestMethod] public async Task Copy() { @@ -183,7 +337,7 @@ private int GetBoreholeIdToCopy() .Where(b => b.Stratigraphies != null && b.Stratigraphies.Any() && - b.Stratigraphies.First().Layers != null && +b.Stratigraphies.First().Layers != null && b.Stratigraphies.First().Layers.Any(x => x.LayerColorCodes != null && x.LayerColorCodes.Any()) && b.Stratigraphies.First().Layers.Any(x => x.LayerGrainShapeCodes != null && x.LayerGrainShapeCodes.Any()) && b.Stratigraphies.First().Layers.Any(x => x.LayerUscs3Codes != null && x.LayerUscs3Codes.Any()) && From edadad564033027593e1bb8fb4e6f32cc59d78b7 Mon Sep 17 00:00:00 2001 From: MiraGeowerkstatt Date: Thu, 3 Oct 2024 15:58:06 +0200 Subject: [PATCH 2/7] fix style offense --- tests/Controllers/BoreholeControllerTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Controllers/BoreholeControllerTest.cs b/tests/Controllers/BoreholeControllerTest.cs index 35390076c..9c31e6569 100644 --- a/tests/Controllers/BoreholeControllerTest.cs +++ b/tests/Controllers/BoreholeControllerTest.cs @@ -337,7 +337,7 @@ private int GetBoreholeIdToCopy() .Where(b => b.Stratigraphies != null && b.Stratigraphies.Any() && -b.Stratigraphies.First().Layers != null && + b.Stratigraphies.First().Layers != null && b.Stratigraphies.First().Layers.Any(x => x.LayerColorCodes != null && x.LayerColorCodes.Any()) && b.Stratigraphies.First().Layers.Any(x => x.LayerGrainShapeCodes != null && x.LayerGrainShapeCodes.Any()) && b.Stratigraphies.First().Layers.Any(x => x.LayerUscs3Codes != null && x.LayerUscs3Codes.Any()) && From 21ca443e44307b5c79ae255602356ad72b719764 Mon Sep 17 00:00:00 2001 From: MiraGeowerkstatt Date: Mon, 7 Oct 2024 14:25:33 +0200 Subject: [PATCH 3/7] Fix api version for borehole controller --- src/api/Controllers/BoreholeController.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/api/Controllers/BoreholeController.cs b/src/api/Controllers/BoreholeController.cs index 698446b9c..9278d859a 100644 --- a/src/api/Controllers/BoreholeController.cs +++ b/src/api/Controllers/BoreholeController.cs @@ -7,8 +7,10 @@ namespace BDMS.Controllers; +// The api version is temporarily hardcoded as "v2" until the legacy API for borehole is removed. +// This is necessary to avoid a rerouting issue with the reverse proxy, when matching routes exist for both the .net and the python api. [ApiController] -[Route("api/v{version:apiVersion}/[controller]")] +[Route("api/v2/[controller]")] public class BoreholeController : BoreholeControllerBase { public BoreholeController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) From ed9d989355c0f9f8d144a9b8a100a1b3cc1c9c5a Mon Sep 17 00:00:00 2001 From: MiraGeowerkstatt Date: Tue, 8 Oct 2024 08:57:44 +0200 Subject: [PATCH 4/7] Update Test fix naming and comment --- src/api/Controllers/BoreholeController.cs | 2 +- tests/Controllers/BoreholeControllerTest.cs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/api/Controllers/BoreholeController.cs b/src/api/Controllers/BoreholeController.cs index 9278d859a..55d06a6ce 100644 --- a/src/api/Controllers/BoreholeController.cs +++ b/src/api/Controllers/BoreholeController.cs @@ -8,7 +8,7 @@ namespace BDMS.Controllers; // The api version is temporarily hardcoded as "v2" until the legacy API for borehole is removed. -// This is necessary to avoid a rerouting issue with the reverse proxy, when matching routes exist for both the .net and the python api. +// This is necessary to avoid a rerouting issue with the reverse proxy, when matching routes exist for both the .net and the python API. [ApiController] [Route("api/v2/[controller]")] public class BoreholeController : BoreholeControllerBase diff --git a/tests/Controllers/BoreholeControllerTest.cs b/tests/Controllers/BoreholeControllerTest.cs index 9c31e6569..2ccc5e332 100644 --- a/tests/Controllers/BoreholeControllerTest.cs +++ b/tests/Controllers/BoreholeControllerTest.cs @@ -147,6 +147,11 @@ public async Task EditBoreholeWithCompleteBorehole() // Stratigraphies and workflows remain unchanged Assert.AreEqual(1, updatedBorehole.Stratigraphies.Count); Assert.AreEqual(0, updatedBorehole.Workflows.Count); + Assert.AreEqual(0, updatedBorehole.BoreholeFiles.Count); + Assert.AreEqual(0, updatedBorehole.BoreholeGeometry.Count); + Assert.AreEqual(0, updatedBorehole.Completions.Count); + Assert.AreEqual(0, updatedBorehole.Observations.Count); // Hydrogeology observations + Assert.AreEqual(0, updatedBorehole.Sections.Count); } [TestMethod] @@ -171,7 +176,7 @@ public async Task EditWithoutBoreholeReturnsBadRequest() } [TestMethod] - public async Task EditWithWrongCodelistCodesReturnsBadRequest() + public async Task EditWithWrongCodelistCodesReturnsInternalServerError() { var borehole = new Borehole { From 3660391d521029892525760e5348ee7c7fa7a52e Mon Sep 17 00:00:00 2001 From: MiraGeowerkstatt Date: Tue, 8 Oct 2024 09:33:15 +0200 Subject: [PATCH 5/7] Fix ILogger type in BoreholeControllerBase --- src/api/Controllers/BackfillController.cs | 2 +- src/api/Controllers/BoreholeController.cs | 4 +++- src/api/Controllers/BoreholeControllerBase.cs | 6 +++--- src/api/Controllers/CasingController.cs | 2 +- src/api/Controllers/ChronostratigraphyController.cs | 2 +- src/api/Controllers/CompletionController.cs | 2 +- src/api/Controllers/FaciesDescriptionController.cs | 2 +- src/api/Controllers/FieldMeasurementController.cs | 2 +- .../Controllers/GroundwaterLevelMeasurementController.cs | 2 +- src/api/Controllers/HydrotestController.cs | 2 +- src/api/Controllers/InstrumentationController.cs | 2 +- src/api/Controllers/LayerController.cs | 2 +- src/api/Controllers/LithologicalDescriptionController.cs | 2 +- src/api/Controllers/LithostratigraphyController.cs | 2 +- src/api/Controllers/SectionController.cs | 2 +- src/api/Controllers/StratigraphyController.cs | 2 +- src/api/Controllers/WaterIngressController.cs | 2 +- tests/Controllers/BackfillControllerTest.cs | 2 +- tests/Controllers/BoreholeControllerTest.cs | 2 +- tests/Controllers/CasingControllerTest.cs | 2 +- tests/Controllers/ChronostratigraphyControllerTest.cs | 2 +- tests/Controllers/CompletionControllerTest.cs | 4 ++-- tests/Controllers/FaciesDescriptionControllerTest.cs | 2 +- tests/Controllers/FieldMeasurementControllerTest.cs | 2 +- .../GroundwaterLevelMeasurementControllerTest.cs | 2 +- tests/Controllers/HydrotestControllerTest.cs | 2 +- tests/Controllers/InstrumentationControllerTest.cs | 2 +- tests/Controllers/LayerControllerTest.cs | 2 +- tests/Controllers/LithologicalDescriptionControllerTest.cs | 2 +- tests/Controllers/LithostratigraphyControllerTest.cs | 2 +- tests/Controllers/SectionControllerTest.cs | 2 +- tests/Controllers/StratigraphyControllerTest.cs | 4 ++-- tests/Controllers/WaterIngressControllerTest.cs | 2 +- 33 files changed, 39 insertions(+), 37 deletions(-) diff --git a/src/api/Controllers/BackfillController.cs b/src/api/Controllers/BackfillController.cs index f14e580f0..3e85b7fdf 100644 --- a/src/api/Controllers/BackfillController.cs +++ b/src/api/Controllers/BackfillController.cs @@ -10,7 +10,7 @@ namespace BDMS.Controllers; [Route("api/v{version:apiVersion}/[controller]")] public class BackfillController : BoreholeControllerBase { - public BackfillController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) + public BackfillController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) : base(context, logger, boreholeLockService) { } diff --git a/src/api/Controllers/BoreholeController.cs b/src/api/Controllers/BoreholeController.cs index 55d06a6ce..471594e73 100644 --- a/src/api/Controllers/BoreholeController.cs +++ b/src/api/Controllers/BoreholeController.cs @@ -13,7 +13,7 @@ namespace BDMS.Controllers; [Route("api/v2/[controller]")] public class BoreholeController : BoreholeControllerBase { - public BoreholeController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) + public BoreholeController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) : base(context, logger, boreholeLockService) { } @@ -22,6 +22,8 @@ public BoreholeController(BdmsContext context, ILogger logger, IBoreho [Authorize(Policy = PolicyNames.Viewer)] public async override Task> EditAsync(Borehole entity) { + Logger.LogInformation("Put borehole"); + if (entity == null) { return BadRequest(ModelState); diff --git a/src/api/Controllers/BoreholeControllerBase.cs b/src/api/Controllers/BoreholeControllerBase.cs index 9a44b4e3b..662542cd6 100644 --- a/src/api/Controllers/BoreholeControllerBase.cs +++ b/src/api/Controllers/BoreholeControllerBase.cs @@ -13,7 +13,7 @@ public abstract class BoreholeControllerBase : ControllerBase where TEntity : IIdentifyable, IChangeTracking, new() { private readonly BdmsContext context; - private readonly ILogger logger; + private readonly ILogger> logger; private readonly IBoreholeLockService boreholeLockService; /// @@ -24,14 +24,14 @@ public abstract class BoreholeControllerBase : ControllerBase /// /// Gets the used by the controller. /// - protected ILogger Logger => logger; + protected ILogger> Logger => logger; /// /// Gets the used by the controller. /// protected IBoreholeLockService BoreholeLockService => boreholeLockService; - protected BoreholeControllerBase(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) + protected BoreholeControllerBase(BdmsContext context, ILogger> logger, IBoreholeLockService boreholeLockService) { this.context = context; this.logger = logger; diff --git a/src/api/Controllers/CasingController.cs b/src/api/Controllers/CasingController.cs index b28f08cb7..3039edf9b 100644 --- a/src/api/Controllers/CasingController.cs +++ b/src/api/Controllers/CasingController.cs @@ -11,7 +11,7 @@ namespace BDMS.Controllers; [Route("api/v{version:apiVersion}/[controller]")] public class CasingController : BoreholeControllerBase { - public CasingController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) + public CasingController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) : base(context, logger, boreholeLockService) { } diff --git a/src/api/Controllers/ChronostratigraphyController.cs b/src/api/Controllers/ChronostratigraphyController.cs index 60f8892f7..e15376731 100644 --- a/src/api/Controllers/ChronostratigraphyController.cs +++ b/src/api/Controllers/ChronostratigraphyController.cs @@ -10,7 +10,7 @@ namespace BDMS.Controllers; [Route("api/v{version:apiVersion}/[controller]")] public class ChronostratigraphyController : BoreholeControllerBase { - public ChronostratigraphyController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) + public ChronostratigraphyController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) : base(context, logger, boreholeLockService) { } diff --git a/src/api/Controllers/CompletionController.cs b/src/api/Controllers/CompletionController.cs index 80cfd2cd0..6676df665 100644 --- a/src/api/Controllers/CompletionController.cs +++ b/src/api/Controllers/CompletionController.cs @@ -12,7 +12,7 @@ namespace BDMS.Controllers; [Route("api/v{version:apiVersion}/[controller]")] public class CompletionController : BoreholeControllerBase { - public CompletionController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) + public CompletionController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) : base(context, logger, boreholeLockService) { } diff --git a/src/api/Controllers/FaciesDescriptionController.cs b/src/api/Controllers/FaciesDescriptionController.cs index c61a3442f..c0f4d1017 100644 --- a/src/api/Controllers/FaciesDescriptionController.cs +++ b/src/api/Controllers/FaciesDescriptionController.cs @@ -10,7 +10,7 @@ namespace BDMS.Controllers; [Route("api/v{version:apiVersion}/[controller]")] public class FaciesDescriptionController : BoreholeControllerBase { - public FaciesDescriptionController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) + public FaciesDescriptionController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) : base(context, logger, boreholeLockService) { } diff --git a/src/api/Controllers/FieldMeasurementController.cs b/src/api/Controllers/FieldMeasurementController.cs index 260cdeaed..f27c130ff 100644 --- a/src/api/Controllers/FieldMeasurementController.cs +++ b/src/api/Controllers/FieldMeasurementController.cs @@ -10,7 +10,7 @@ namespace BDMS.Controllers; [Route("api/v{version:apiVersion}/[controller]")] public class FieldMeasurementController : BoreholeControllerBase { - public FieldMeasurementController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) + public FieldMeasurementController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) : base(context, logger, boreholeLockService) { } diff --git a/src/api/Controllers/GroundwaterLevelMeasurementController.cs b/src/api/Controllers/GroundwaterLevelMeasurementController.cs index 61def43c2..2957f0ed8 100644 --- a/src/api/Controllers/GroundwaterLevelMeasurementController.cs +++ b/src/api/Controllers/GroundwaterLevelMeasurementController.cs @@ -10,7 +10,7 @@ namespace BDMS.Controllers; [Route("api/v{version:apiVersion}/[controller]")] public class GroundwaterLevelMeasurementController : BoreholeControllerBase { - public GroundwaterLevelMeasurementController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) + public GroundwaterLevelMeasurementController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) : base(context, logger, boreholeLockService) { } diff --git a/src/api/Controllers/HydrotestController.cs b/src/api/Controllers/HydrotestController.cs index e5834b3b6..212fbea0d 100644 --- a/src/api/Controllers/HydrotestController.cs +++ b/src/api/Controllers/HydrotestController.cs @@ -10,7 +10,7 @@ namespace BDMS.Controllers; [Route("api/v{version:apiVersion}/[controller]")] public class HydrotestController : BoreholeControllerBase { - public HydrotestController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) + public HydrotestController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) : base(context, logger, boreholeLockService) { } diff --git a/src/api/Controllers/InstrumentationController.cs b/src/api/Controllers/InstrumentationController.cs index 645ba8499..064f89922 100644 --- a/src/api/Controllers/InstrumentationController.cs +++ b/src/api/Controllers/InstrumentationController.cs @@ -10,7 +10,7 @@ namespace BDMS.Controllers; [Route("api/v{version:apiVersion}/[controller]")] public class InstrumentationController : BoreholeControllerBase { - public InstrumentationController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) + public InstrumentationController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) : base(context, logger, boreholeLockService) { } diff --git a/src/api/Controllers/LayerController.cs b/src/api/Controllers/LayerController.cs index f4da0cc68..b51b458ad 100644 --- a/src/api/Controllers/LayerController.cs +++ b/src/api/Controllers/LayerController.cs @@ -10,7 +10,7 @@ namespace BDMS.Controllers; [Route("api/v{version:apiVersion}/[controller]")] public class LayerController : BoreholeControllerBase { - public LayerController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) + public LayerController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) : base(context, logger, boreholeLockService) { } diff --git a/src/api/Controllers/LithologicalDescriptionController.cs b/src/api/Controllers/LithologicalDescriptionController.cs index 281513a88..5275e18f1 100644 --- a/src/api/Controllers/LithologicalDescriptionController.cs +++ b/src/api/Controllers/LithologicalDescriptionController.cs @@ -10,7 +10,7 @@ namespace BDMS.Controllers; [Route("api/v{version:apiVersion}/[controller]")] public class LithologicalDescriptionController : BoreholeControllerBase { - public LithologicalDescriptionController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) + public LithologicalDescriptionController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) : base(context, logger, boreholeLockService) { } diff --git a/src/api/Controllers/LithostratigraphyController.cs b/src/api/Controllers/LithostratigraphyController.cs index 01546714e..7e37d2ac2 100644 --- a/src/api/Controllers/LithostratigraphyController.cs +++ b/src/api/Controllers/LithostratigraphyController.cs @@ -10,7 +10,7 @@ namespace BDMS.Controllers; [Route("api/v{version:apiVersion}/[controller]")] public class LithostratigraphyController : BoreholeControllerBase { - public LithostratigraphyController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) + public LithostratigraphyController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) : base(context, logger, boreholeLockService) { } diff --git a/src/api/Controllers/SectionController.cs b/src/api/Controllers/SectionController.cs index abcc40751..20a44a636 100644 --- a/src/api/Controllers/SectionController.cs +++ b/src/api/Controllers/SectionController.cs @@ -10,7 +10,7 @@ namespace BDMS.Controllers; [Route("api/v{version:apiVersion}/[controller]")] public class SectionController : BoreholeControllerBase
{ - public SectionController(BdmsContext context, ILogger
logger, IBoreholeLockService boreholeLockService) + public SectionController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) : base(context, logger, boreholeLockService) { } diff --git a/src/api/Controllers/StratigraphyController.cs b/src/api/Controllers/StratigraphyController.cs index a0948f995..7ed184652 100644 --- a/src/api/Controllers/StratigraphyController.cs +++ b/src/api/Controllers/StratigraphyController.cs @@ -11,7 +11,7 @@ namespace BDMS.Controllers; [Route("api/v{version:apiVersion}/[controller]")] public class StratigraphyController : BoreholeControllerBase { - public StratigraphyController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) + public StratigraphyController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) : base(context, logger, boreholeLockService) { } diff --git a/src/api/Controllers/WaterIngressController.cs b/src/api/Controllers/WaterIngressController.cs index beec526a1..ec9bdbe8f 100644 --- a/src/api/Controllers/WaterIngressController.cs +++ b/src/api/Controllers/WaterIngressController.cs @@ -11,7 +11,7 @@ namespace BDMS.Controllers; [Route("api/v{version:apiVersion}/[controller]")] public class WaterIngressController : BoreholeControllerBase { - public WaterIngressController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) + public WaterIngressController(BdmsContext context, ILogger logger, IBoreholeLockService boreholeLockService) : base(context, logger, boreholeLockService) { } diff --git a/tests/Controllers/BackfillControllerTest.cs b/tests/Controllers/BackfillControllerTest.cs index 19a60c90f..0ff2f235c 100644 --- a/tests/Controllers/BackfillControllerTest.cs +++ b/tests/Controllers/BackfillControllerTest.cs @@ -22,7 +22,7 @@ public void TestInitialize() boreholeLockServiceMock .Setup(x => x.IsBoreholeLockedAsync(It.IsAny(), It.IsAny())) .ReturnsAsync(false); - controller = new BackfillController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; + controller = new BackfillController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; } [TestCleanup] diff --git a/tests/Controllers/BoreholeControllerTest.cs b/tests/Controllers/BoreholeControllerTest.cs index 2ccc5e332..a605f7e62 100644 --- a/tests/Controllers/BoreholeControllerTest.cs +++ b/tests/Controllers/BoreholeControllerTest.cs @@ -27,7 +27,7 @@ public void TestInitialize() boreholeLockServiceMock .Setup(x => x.IsBoreholeLockedAsync(It.IsAny(), It.IsAny())) .ReturnsAsync(false); - controller = new BoreholeController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; + controller = new BoreholeController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; boreholeId = GetBoreholeIdToCopy(); } diff --git a/tests/Controllers/CasingControllerTest.cs b/tests/Controllers/CasingControllerTest.cs index 3d9e5ea21..739032028 100644 --- a/tests/Controllers/CasingControllerTest.cs +++ b/tests/Controllers/CasingControllerTest.cs @@ -24,7 +24,7 @@ public void TestInitialize() boreholeLockServiceMock .Setup(x => x.IsBoreholeLockedAsync(It.IsAny(), It.IsAny())) .ReturnsAsync(false); - controller = new CasingController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; + controller = new CasingController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; } [TestCleanup] diff --git a/tests/Controllers/ChronostratigraphyControllerTest.cs b/tests/Controllers/ChronostratigraphyControllerTest.cs index 9a9dd5f6a..faea5d2ae 100644 --- a/tests/Controllers/ChronostratigraphyControllerTest.cs +++ b/tests/Controllers/ChronostratigraphyControllerTest.cs @@ -21,7 +21,7 @@ public void TestInitialize() boreholeLockServiceMock .Setup(x => x.IsBoreholeLockedAsync(It.IsAny(), It.IsAny())) .ReturnsAsync(false); - controller = new ChronostratigraphyController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; + controller = new ChronostratigraphyController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; } [TestCleanup] diff --git a/tests/Controllers/CompletionControllerTest.cs b/tests/Controllers/CompletionControllerTest.cs index 45d95ff40..699843c91 100644 --- a/tests/Controllers/CompletionControllerTest.cs +++ b/tests/Controllers/CompletionControllerTest.cs @@ -25,7 +25,7 @@ public void TestInitialize() boreholeLockServiceMock .Setup(x => x.IsBoreholeLockedAsync(It.IsAny(), It.IsAny())) .ReturnsAsync(false); - controller = new CompletionController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; + controller = new CompletionController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; } [TestCleanup] @@ -458,6 +458,6 @@ private void SetupControllerWithAlwaysLockedBorehole() .Setup(x => x.IsBoreholeLockedAsync(It.IsAny(), It.IsAny())) .ReturnsAsync(true); - controller = new CompletionController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; + controller = new CompletionController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; } } diff --git a/tests/Controllers/FaciesDescriptionControllerTest.cs b/tests/Controllers/FaciesDescriptionControllerTest.cs index 8a4cb8423..ca84b9ca5 100644 --- a/tests/Controllers/FaciesDescriptionControllerTest.cs +++ b/tests/Controllers/FaciesDescriptionControllerTest.cs @@ -21,7 +21,7 @@ public void TestInitialize() boreholeLockServiceMock .Setup(x => x.IsBoreholeLockedAsync(It.IsAny(), It.IsAny())) .ReturnsAsync(false); - controller = new FaciesDescriptionController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; + controller = new FaciesDescriptionController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; } [TestCleanup] diff --git a/tests/Controllers/FieldMeasurementControllerTest.cs b/tests/Controllers/FieldMeasurementControllerTest.cs index 1efedc060..7bc6fcd78 100644 --- a/tests/Controllers/FieldMeasurementControllerTest.cs +++ b/tests/Controllers/FieldMeasurementControllerTest.cs @@ -22,7 +22,7 @@ public void TestInitialize() boreholeLockServiceMock .Setup(x => x.IsBoreholeLockedAsync(It.IsAny(), It.IsAny())) .ReturnsAsync(false); - controller = new FieldMeasurementController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; + controller = new FieldMeasurementController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; } [TestCleanup] diff --git a/tests/Controllers/GroundwaterLevelMeasurementControllerTest.cs b/tests/Controllers/GroundwaterLevelMeasurementControllerTest.cs index 0dd8d75de..5df6b2ec8 100644 --- a/tests/Controllers/GroundwaterLevelMeasurementControllerTest.cs +++ b/tests/Controllers/GroundwaterLevelMeasurementControllerTest.cs @@ -23,7 +23,7 @@ public void TestInitialize() boreholeLockServiceMock .Setup(x => x.IsBoreholeLockedAsync(It.IsAny(), It.IsAny())) .ReturnsAsync(false); - controller = new GroundwaterLevelMeasurementController(context, new Mock>().Object, boreholeLockServiceMock.Object) + controller = new GroundwaterLevelMeasurementController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = new ControllerContext { diff --git a/tests/Controllers/HydrotestControllerTest.cs b/tests/Controllers/HydrotestControllerTest.cs index c9a86f45f..5b84e38e2 100644 --- a/tests/Controllers/HydrotestControllerTest.cs +++ b/tests/Controllers/HydrotestControllerTest.cs @@ -24,7 +24,7 @@ public void TestInitialize() boreholeLockServiceMock .Setup(x => x.IsBoreholeLockedAsync(It.IsAny(), It.IsAny())) .ReturnsAsync(false); - controller = new HydrotestController(context, new Mock>().Object, boreholeLockServiceMock.Object) + controller = new HydrotestController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = new ControllerContext { diff --git a/tests/Controllers/InstrumentationControllerTest.cs b/tests/Controllers/InstrumentationControllerTest.cs index 194f2b78f..96ced3faf 100644 --- a/tests/Controllers/InstrumentationControllerTest.cs +++ b/tests/Controllers/InstrumentationControllerTest.cs @@ -22,7 +22,7 @@ public void TestInitialize() boreholeLockServiceMock .Setup(x => x.IsBoreholeLockedAsync(It.IsAny(), It.IsAny())) .ReturnsAsync(false); - controller = new InstrumentationController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; + controller = new InstrumentationController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; } [TestCleanup] diff --git a/tests/Controllers/LayerControllerTest.cs b/tests/Controllers/LayerControllerTest.cs index 7d056e961..737722152 100644 --- a/tests/Controllers/LayerControllerTest.cs +++ b/tests/Controllers/LayerControllerTest.cs @@ -21,7 +21,7 @@ public void TestInitialize() boreholeLockServiceMock .Setup(x => x.IsBoreholeLockedAsync(It.IsAny(), It.IsAny())) .ReturnsAsync(false); - controller = new LayerController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; + controller = new LayerController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; } [TestCleanup] diff --git a/tests/Controllers/LithologicalDescriptionControllerTest.cs b/tests/Controllers/LithologicalDescriptionControllerTest.cs index 528f08b86..d4ac9a77b 100644 --- a/tests/Controllers/LithologicalDescriptionControllerTest.cs +++ b/tests/Controllers/LithologicalDescriptionControllerTest.cs @@ -21,7 +21,7 @@ public void TestInitialize() boreholeLockServiceMock .Setup(x => x.IsBoreholeLockedAsync(It.IsAny(), It.IsAny())) .ReturnsAsync(false); - controller = new LithologicalDescriptionController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; + controller = new LithologicalDescriptionController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; } [TestCleanup] diff --git a/tests/Controllers/LithostratigraphyControllerTest.cs b/tests/Controllers/LithostratigraphyControllerTest.cs index 7902f6c0f..6af0b1975 100644 --- a/tests/Controllers/LithostratigraphyControllerTest.cs +++ b/tests/Controllers/LithostratigraphyControllerTest.cs @@ -33,7 +33,7 @@ public void TestInitialize() boreholeLockServiceMock .Setup(x => x.IsBoreholeLockedAsync(It.IsAny(), It.IsAny())) .ReturnsAsync(false); - controller = new LithostratigraphyController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; + controller = new LithostratigraphyController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; } [TestCleanup] diff --git a/tests/Controllers/SectionControllerTest.cs b/tests/Controllers/SectionControllerTest.cs index 6633a952f..aca92daf7 100644 --- a/tests/Controllers/SectionControllerTest.cs +++ b/tests/Controllers/SectionControllerTest.cs @@ -23,7 +23,7 @@ public void TestInitialize() boreholeLockServiceMock .Setup(x => x.IsBoreholeLockedAsync(It.IsAny(), It.IsAny())) .ReturnsAsync(false); - controller = new SectionController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; + controller = new SectionController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; } [TestCleanup] diff --git a/tests/Controllers/StratigraphyControllerTest.cs b/tests/Controllers/StratigraphyControllerTest.cs index 451bf4b3d..28be77d92 100644 --- a/tests/Controllers/StratigraphyControllerTest.cs +++ b/tests/Controllers/StratigraphyControllerTest.cs @@ -27,7 +27,7 @@ public void TestInitialize() .Setup(x => x.IsBoreholeLockedAsync(It.IsAny(), It.IsAny())) .ReturnsAsync(false); - controller = new StratigraphyController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; + controller = new StratigraphyController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; } [TestCleanup] @@ -460,6 +460,6 @@ private void SetupControllerWithAlwaysLockedBorehole() .Setup(x => x.IsBoreholeLockedAsync(It.IsAny(), It.IsAny())) .ReturnsAsync(true); - controller = new StratigraphyController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; + controller = new StratigraphyController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = GetControllerContextAdmin() }; } } diff --git a/tests/Controllers/WaterIngressControllerTest.cs b/tests/Controllers/WaterIngressControllerTest.cs index d00c09b49..0e6d2eabd 100644 --- a/tests/Controllers/WaterIngressControllerTest.cs +++ b/tests/Controllers/WaterIngressControllerTest.cs @@ -24,7 +24,7 @@ public void TestInitialize() boreholeLockServiceMock .Setup(x => x.IsBoreholeLockedAsync(It.IsAny(), It.IsAny())) .ReturnsAsync(false); - controller = new WaterIngressController(context, new Mock>().Object, boreholeLockServiceMock.Object) + controller = new WaterIngressController(context, new Mock>().Object, boreholeLockServiceMock.Object) { ControllerContext = new ControllerContext { From fc991f66dc4f47514edcb7dc3491055d88bf6c0c Mon Sep 17 00:00:00 2001 From: MiraGeowerkstatt Date: Tue, 8 Oct 2024 09:41:14 +0200 Subject: [PATCH 6/7] Update test --- tests/Controllers/BoreholeControllerTest.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/Controllers/BoreholeControllerTest.cs b/tests/Controllers/BoreholeControllerTest.cs index a605f7e62..37e6c596c 100644 --- a/tests/Controllers/BoreholeControllerTest.cs +++ b/tests/Controllers/BoreholeControllerTest.cs @@ -92,6 +92,11 @@ public async Task EditBoreholeWithCompleteBorehole() var boreholeToEdit = context.Boreholes.Single(c => c.Id == id); Assert.AreEqual(1, boreholeToEdit.Stratigraphies.Count); Assert.AreEqual(0, boreholeToEdit.Workflows.Count); + Assert.AreEqual(0, boreholeToEdit.BoreholeFiles.Count); + Assert.AreEqual(0, boreholeToEdit.BoreholeGeometry.Count); + Assert.AreEqual(0, boreholeToEdit.Completions.Count); + Assert.AreEqual(0, boreholeToEdit.Observations.Count); // Hydrogeology observations + Assert.AreEqual(0, boreholeToEdit.Sections.Count); Assert.AreEqual(2, boreholeToEdit.CreatedById); Assert.AreEqual(5, boreholeToEdit.UpdatedById); @@ -150,7 +155,7 @@ public async Task EditBoreholeWithCompleteBorehole() Assert.AreEqual(0, updatedBorehole.BoreholeFiles.Count); Assert.AreEqual(0, updatedBorehole.BoreholeGeometry.Count); Assert.AreEqual(0, updatedBorehole.Completions.Count); - Assert.AreEqual(0, updatedBorehole.Observations.Count); // Hydrogeology observations + Assert.AreEqual(0, updatedBorehole.Observations.Count); Assert.AreEqual(0, updatedBorehole.Sections.Count); } From b807c4ae90704f46b6a59153c883abc4316e401d Mon Sep 17 00:00:00 2001 From: MiraGeowerkstatt Date: Tue, 8 Oct 2024 09:41:24 +0200 Subject: [PATCH 7/7] Remove debug log --- src/api/Controllers/BoreholeController.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/api/Controllers/BoreholeController.cs b/src/api/Controllers/BoreholeController.cs index 471594e73..99b689b0c 100644 --- a/src/api/Controllers/BoreholeController.cs +++ b/src/api/Controllers/BoreholeController.cs @@ -22,8 +22,6 @@ public BoreholeController(BdmsContext context, ILogger logge [Authorize(Policy = PolicyNames.Viewer)] public async override Task> EditAsync(Borehole entity) { - Logger.LogInformation("Put borehole"); - if (entity == null) { return BadRequest(ModelState);