diff --git a/src/Controllers/DebugUsersController.cs b/src/Controllers/DebugUsersController.cs index 6dfa0289..d31012bc 100644 --- a/src/Controllers/DebugUsersController.cs +++ b/src/Controllers/DebugUsersController.cs @@ -1,14 +1,10 @@ #nullable enable -using System.Text.Json; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; -using Altinn.Platform.Storage.Repository; using LocalTest.Configuration; -using LocalTest.Models; -using LocalTest.Services.LocalApp.Interface; using LocalTest.Services.TestData; using Microsoft.AspNetCore.Authorization; @@ -18,57 +14,52 @@ namespace LocalTest.Controllers; [Route("Home/[controller]/[action]")] public class DebugUsersController : Controller { - private readonly TenorDataRepository _tenorDataRepository; private readonly LocalPlatformSettings _localPlatformSettings; - private readonly ILocalApp _localApp; + private readonly TenorDataRepository _tenorDataRepository; public DebugUsersController( - TenorDataRepository tenorDataRepository, IOptions localPlatformSettings, - ILocalApp localApp) + TenorDataRepository tenorDataRepository) { - _tenorDataRepository = tenorDataRepository; _localPlatformSettings = localPlatformSettings.Value; - _localApp = localApp; + _tenorDataRepository = tenorDataRepository; } - // Debugging endpoint - [AllowAnonymous] - public async Task LocalTestUsersRaw() - { - var localData = await TestDataDiskReader.ReadFromDisk(_localPlatformSettings.LocalTestingStaticTestDataPath); - - return Json(localData); - } - - //Debugging endpoint - [AllowAnonymous] - public async Task LocalTestUsers() - { - var localData = await TestDataDiskReader.ReadFromDisk(_localPlatformSettings.LocalTestingStaticTestDataPath); - var constructedAppData = AppTestDataModel.FromTestDataModel(localData); + // Debugging endpoint + [AllowAnonymous] + public async Task LocalTestUsersRaw() + { + var localData = await TestDataDiskReader.ReadFromDisk(_localPlatformSettings.LocalTestingStaticTestDataPath); - return Json(constructedAppData); - } + return Json(localData); + } - // Debugging endpoint - [AllowAnonymous] - public async Task LocalTestUsersRoundTrip() - { - var localData = await TestDataDiskReader.ReadFromDisk(_localPlatformSettings.LocalTestingStaticTestDataPath); - var constructedAppData = AppTestDataModel.FromTestDataModel(localData); + //Debugging endpoint + [AllowAnonymous] + public async Task LocalTestUsers() + { + var localData = await TestDataDiskReader.ReadFromDisk(_localPlatformSettings.LocalTestingStaticTestDataPath); + var constructedAppData = AppTestDataModel.FromTestDataModel(localData); - return Json(constructedAppData.GetTestDataModel()); - } + return Json(constructedAppData); + } - // Debugging endpoint - [AllowAnonymous] - public async Task ShowTenorUsers([FromServices] TenorDataRepository tenorDataRepository) - { - var localData = await tenorDataRepository.GetAppTestDataModel(); + // Debugging endpoint + [AllowAnonymous] + public async Task LocalTestUsersRoundTrip() + { + var localData = await TestDataDiskReader.ReadFromDisk(_localPlatformSettings.LocalTestingStaticTestDataPath); + var constructedAppData = AppTestDataModel.FromTestDataModel(localData); - return Json(localData); - } + return Json(constructedAppData.GetTestDataModel()); + } + // Debugging endpoint + [AllowAnonymous] + public async Task ShowTenorUsers() + { + var localData = await _tenorDataRepository.GetAppTestDataModel(); + return Json(localData); + } } \ No newline at end of file diff --git a/src/Controllers/FrontendVersionController.cs b/src/Controllers/FrontendVersionController.cs index f22e496f..74db638f 100644 --- a/src/Controllers/FrontendVersionController.cs +++ b/src/Controllers/FrontendVersionController.cs @@ -4,14 +4,11 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; -using Altinn.Platform.Storage.Repository; - using LocalTest.Configuration; using LocalTest.Models; using LocalTest.Services.LocalApp.Interface; using LocalTest.Services.TestData; -using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Mvc.Rendering; @@ -20,19 +17,6 @@ namespace LocalTest.Controllers; [Route("Home/[controller]/[action]")] public class FrontendVersionController : Controller { - private readonly TenorDataRepository _tenorDataRepository; - private readonly LocalPlatformSettings _localPlatformSettings; - private readonly ILocalApp _localApp; - - public FrontendVersionController( - TenorDataRepository tenorDataRepository, - IOptions localPlatformSettings, - ILocalApp localApp) - { - _tenorDataRepository = tenorDataRepository; - _localPlatformSettings = localPlatformSettings.Value; - _localApp = localApp; - } /// /// See src\development\loadbalancer\nginx.conf /// diff --git a/src/Controllers/HomeController.cs b/src/Controllers/HomeController.cs index 2a2f202d..945b881c 100644 --- a/src/Controllers/HomeController.cs +++ b/src/Controllers/HomeController.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using System.Text.Json; using System.Xml; using Microsoft.AspNetCore.Authentication; diff --git a/src/Controllers/StorageExplorerController.cs b/src/Controllers/StorageExplorerController.cs index 3970ec0c..7085cf93 100644 --- a/src/Controllers/StorageExplorerController.cs +++ b/src/Controllers/StorageExplorerController.cs @@ -1,37 +1,12 @@ #nullable enable -using System.Text.Json; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Options; - -using Altinn.Platform.Storage.Repository; - -using LocalTest.Configuration; -using LocalTest.Models; -using LocalTest.Services.LocalApp.Interface; - -using LocalTest.Services.TestData; -using Microsoft.AspNetCore.Authorization; namespace LocalTest.Controllers; [Route("Home/[controller]/[action]")] public class StorageExplorerController : Controller { - private readonly TenorDataRepository _tenorDataRepository; - private readonly LocalPlatformSettings _localPlatformSettings; - private readonly ILocalApp _localApp; - - public StorageExplorerController( - TenorDataRepository tenorDataRepository, - IOptions localPlatformSettings, - ILocalApp localApp) - { - _tenorDataRepository = tenorDataRepository; - _localPlatformSettings = localPlatformSettings.Value; - _localApp = localApp; - } - public IActionResult Index() { return View(); diff --git a/src/Controllers/TenorUsersController.cs b/src/Controllers/TenorUsersController.cs index 76492eef..d5c39abe 100644 --- a/src/Controllers/TenorUsersController.cs +++ b/src/Controllers/TenorUsersController.cs @@ -2,11 +2,6 @@ using System.Text.Json; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Options; - -using Altinn.Platform.Storage.Repository; - -using LocalTest.Configuration; using LocalTest.Models; using LocalTest.Services.LocalApp.Interface; @@ -18,27 +13,19 @@ namespace LocalTest.Controllers; public class TenorUsersController : Controller { private readonly TenorDataRepository _tenorDataRepository; - private readonly ILocalApp _localApp; - public TenorUsersController( - TenorDataRepository tenorDataRepository, - ILocalApp localApp) + public TenorUsersController(TenorDataRepository tenorDataRepository) { _tenorDataRepository = tenorDataRepository; - _localApp = localApp; } public async Task Index() { - var appUsers = await _localApp.GetTestData(); - return View(new TenorViewModel() { - AppUsers = appUsers, FileItems = await _tenorDataRepository.GetFileItems(), - }); } diff --git a/src/Models/TenorViewModel.cs b/src/Models/TenorViewModel.cs index d6ae95f6..d1cb4d9a 100644 --- a/src/Models/TenorViewModel.cs +++ b/src/Models/TenorViewModel.cs @@ -7,7 +7,6 @@ namespace LocalTest.Models; public class TenorViewModel { public List FileItems { get; set; } = default!; - public AppTestDataModel? AppUsers { get; set; } } public class TenorFileItem diff --git a/src/Services/Tenor/TenorDataReader.cs b/src/Services/Tenor/TenorDataReader.cs index 45e8300f..d41cfa6c 100644 --- a/src/Services/Tenor/TenorDataReader.cs +++ b/src/Services/Tenor/TenorDataReader.cs @@ -23,7 +23,12 @@ public TenorDataRepository(IOptions settings) public DirectoryInfo GetTenorStorageDirectory() { - return new DirectoryInfo(Path.Join(_settings.LocalTestingStorageBasePath, _settings.TenorDataFolder)); + var dir = new DirectoryInfo(Path.Join(_settings.LocalTestingStorageBasePath, _settings.TenorDataFolder)); + if (!dir.Exists) + { + dir.Create(); + } + return dir; } @@ -32,10 +37,6 @@ public DirectoryInfo GetTenorStorageDirectory() var freg = new List(); var brregErFr = new List(); var tenorFolder = GetTenorStorageDirectory(); - if (!tenorFolder.Exists) - { - return (brregErFr, freg); - } foreach (var fregFile in tenorFolder.GetFiles("freg.*.kildedata.json").Where(f => files?.Contains(f.Name) ?? true)) {