diff --git a/.github/workflows/createrelease.yml b/.github/workflows/createrelease.yml index 919e1277..c1771162 100644 --- a/.github/workflows/createrelease.yml +++ b/.github/workflows/createrelease.yml @@ -14,7 +14,12 @@ jobs: steps: - uses: actions/checkout@v2.3.4 - + + - name: Install NET 9 + uses: actions/setup-dotnet@v4.0.1 + with: + dotnet-version: '9.0.x' + - name: Get the version id: get_version run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} diff --git a/.github/workflows/nightlybuild.yml b/.github/workflows/nightlybuild.yml index 89cc5b53..ed71432b 100644 --- a/.github/workflows/nightlybuild.yml +++ b/.github/workflows/nightlybuild.yml @@ -17,6 +17,11 @@ jobs: steps: - uses: actions/checkout@v2.3.4 + - name: Install NET 9 + uses: actions/setup-dotnet@v4.0.1 + with: + dotnet-version: '9.0.x' + - name: Restore Nuget Packages run: dotnet restore EstateManagementUI.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index 97e9c693..7f6e686e 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -17,6 +17,11 @@ jobs: steps: - uses: actions/checkout@v2.3.4 + - name: Install NET 9 + uses: actions/setup-dotnet@v4.0.1 + with: + dotnet-version: '9.0.x' + - name: Restore Nuget Packages run: dotnet restore EstateManagementUI.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} @@ -40,6 +45,11 @@ jobs: steps: - uses: actions/checkout@v2.3.4 + - name: Install NET 9 + uses: actions/setup-dotnet@v4.0.1 + with: + dotnet-version: '9.0.x' + - name: Trust Certificate run: | sudo apt-get install expect @@ -94,6 +104,11 @@ jobs: steps: - uses: actions/checkout@v2.3.4 + - name: Install NET 9 + uses: actions/setup-dotnet@v4.0.1 + with: + dotnet-version: '9.0.x' + - name: Trust Certificate run: | sudo apt-get install expect @@ -148,6 +163,11 @@ jobs: steps: - uses: actions/checkout@v2.3.4 + - name: Install NET 9 + uses: actions/setup-dotnet@v4.0.1 + with: + dotnet-version: '9.0.x' + - name: Trust Certificate run: | sudo apt-get install expect diff --git a/EstateManagementUI.BusinessLogic.Tests/ApiClientTests.cs b/EstateManagementUI.BusinessLogic.Tests/ApiClientTests.cs index c467dd73..b576fbbb 100644 --- a/EstateManagementUI.BusinessLogic.Tests/ApiClientTests.cs +++ b/EstateManagementUI.BusinessLogic.Tests/ApiClientTests.cs @@ -138,8 +138,8 @@ public async Task ApiClient_GetOperators_ClientCallFailed_ResultFailed() { public async Task ApiClient_GetOperator_OperatorIsReturned() { this.TransactionProcessorClient.Setup(e => e.GetOperator(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.OperatorResponse)); - OperatorModel @operator = await this.ApiClient.GetOperator(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, TestData.Operator1Id, CancellationToken.None); - + Result @operator = await this.ApiClient.GetOperator(TestData.AccessToken, Guid.NewGuid(), TestData.EstateId, TestData.Operator1Id, CancellationToken.None); + @operator.IsSuccess.ShouldBeTrue(); @operator.ShouldNotBeNull(); } diff --git a/EstateManagementUI.BusinessLogic.Tests/EstateManagementUI.BusinessLogic.Tests.csproj b/EstateManagementUI.BusinessLogic.Tests/EstateManagementUI.BusinessLogic.Tests.csproj index d3a58a29..e44957ae 100644 --- a/EstateManagementUI.BusinessLogic.Tests/EstateManagementUI.BusinessLogic.Tests.csproj +++ b/EstateManagementUI.BusinessLogic.Tests/EstateManagementUI.BusinessLogic.Tests.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable None @@ -10,13 +10,13 @@ - - + + - - - - + + + + diff --git a/EstateManagementUI.BusinessLogic/Clients/ApiClient.cs b/EstateManagementUI.BusinessLogic/Clients/ApiClient.cs index b656dfae..5c81eadb 100644 --- a/EstateManagementUI.BusinessLogic/Clients/ApiClient.cs +++ b/EstateManagementUI.BusinessLogic/Clients/ApiClient.cs @@ -294,15 +294,13 @@ public async Task>> GetComparisonDates(String a async Task>> ClientMethod() { - List apiResponse = await this.EstateReportingApiClient.GetComparisonDates(accessToken, estateId, cancellationToken); - - return ModelFactory.ConvertFrom(apiResponse); + Result> apiResponse = await this.EstateReportingApiClient.GetComparisonDates(accessToken, estateId, cancellationToken); + if (apiResponse.IsFailed) + return ResultHelpers.CreateFailure(apiResponse); + return ModelFactory.ConvertFrom(apiResponse.Data); } return await this.CallClientMethod(ClientMethod, cancellationToken); - //List apiResponse = await this.EstateReportingApiClient.GetComparisonDates(accessToken, estateId, cancellationToken); - - //return Result.Success(ModelFactory.ConvertFrom(apiResponse)); } public async Task> GetTodaysSales(String accessToken, @@ -313,9 +311,10 @@ public async Task> GetTodaysSales(String accessToken, DateTime comparisonDate, CancellationToken cancellationToken) { async Task> ClientMethod() { - TodaysSales apiResponse = await this.EstateReportingApiClient.GetTodaysSales(accessToken, estateId, merchantReportingId.GetValueOrDefault(0), operatorReportingId.GetValueOrDefault(0), comparisonDate, cancellationToken); - - return ModelFactory.ConvertFrom(apiResponse); + Result apiResponse = await this.EstateReportingApiClient.GetTodaysSales(accessToken, estateId, merchantReportingId.GetValueOrDefault(0), operatorReportingId.GetValueOrDefault(0), comparisonDate, cancellationToken); + if (apiResponse.IsFailed) + return ResultHelpers.CreateFailure(apiResponse); + return ModelFactory.ConvertFrom(apiResponse.Data); } return await this.CallClientMethod(ClientMethod, cancellationToken); @@ -329,9 +328,10 @@ public async Task> GetTodaysSettlement(String acce DateTime comparisonDate, CancellationToken cancellationToken) { async Task> ClientMethod() { - TodaysSettlement apiResponse = await this.EstateReportingApiClient.GetTodaysSettlement(accessToken, estateId, merchantReportingId.GetValueOrDefault(0), operatorReportingId.GetValueOrDefault(0), comparisonDate, cancellationToken); - - return ModelFactory.ConvertFrom(apiResponse); + Result apiResponse = await this.EstateReportingApiClient.GetTodaysSettlement(accessToken, estateId, merchantReportingId.GetValueOrDefault(0), operatorReportingId.GetValueOrDefault(0), comparisonDate, cancellationToken); + if (apiResponse.IsFailed) + return ResultHelpers.CreateFailure(apiResponse); + return ModelFactory.ConvertFrom(apiResponse.Data); } return await this.CallClientMethod(ClientMethod, cancellationToken); @@ -345,9 +345,11 @@ public async Task>> GetTodaysSalesCount DateTime comparisonDate, CancellationToken cancellationToken) { async Task>> ClientMethod() { - List apiResponse = await this.EstateReportingApiClient.GetTodaysSalesCountByHour(accessToken, estateId, 0, 0, comparisonDate, cancellationToken); + Result> apiResponse = await this.EstateReportingApiClient.GetTodaysSalesCountByHour(accessToken, estateId, 0, 0, comparisonDate, cancellationToken); - return ModelFactory.ConvertFrom(apiResponse); + if (apiResponse.IsFailed) + return ResultHelpers.CreateFailure(apiResponse); + return ModelFactory.ConvertFrom(apiResponse.Data); } return await this.CallClientMethod(ClientMethod, cancellationToken); @@ -361,9 +363,11 @@ public async Task>> GetTodaysSalesValue DateTime comparisonDate, CancellationToken cancellationToken) { async Task>> ClientMethod() { - List apiResponse = await this.EstateReportingApiClient.GetTodaysSalesValueByHour(accessToken, estateId, 0, 0, comparisonDate, cancellationToken); + Result> apiResponse = await this.EstateReportingApiClient.GetTodaysSalesValueByHour(accessToken, estateId, 0, 0, comparisonDate, cancellationToken); - return ModelFactory.ConvertFrom(apiResponse); + if (apiResponse.IsFailed) + return ResultHelpers.CreateFailure(apiResponse); + return ModelFactory.ConvertFrom(apiResponse.Data); } return await this.CallClientMethod(ClientMethod, cancellationToken); @@ -373,7 +377,7 @@ private async Task> CallClientMethod(Func>> clientMe CancellationToken cancellationToken) { try { Result clientResult = await clientMethod(); - return Result.Success(clientResult); + return clientResult; } catch (Exception e) { Logger.LogError(e); @@ -385,7 +389,7 @@ private async Task CallClientMethod(Func> clientMethod, CancellationToken cancellationToken) { try { Result clientResult = await clientMethod(); - return Result.Success(clientResult); + return clientResult; } catch (Exception e) { Logger.LogError(e); @@ -399,9 +403,10 @@ public async Task> GetTodaysFailedSales(String accessTo DateTime comparisonDate, CancellationToken cancellationToken) { async Task> ClientMethod() { - TodaysSales apiResponse = await this.EstateReportingApiClient.GetTodaysFailedSales(accessToken, estateId, 0, 0, responseCode, comparisonDate, cancellationToken); - - return ModelFactory.ConvertFrom(apiResponse); + Result apiResponse = await this.EstateReportingApiClient.GetTodaysFailedSales(accessToken, estateId, 0, 0, responseCode, comparisonDate, cancellationToken); + if (apiResponse.IsFailed) + return ResultHelpers.CreateFailure(apiResponse); + return ModelFactory.ConvertFrom(apiResponse.Data); } return await this.CallClientMethod(ClientMethod, cancellationToken); @@ -413,9 +418,10 @@ public async Task>> GetTopBottomOperator Int32 resultCount, CancellationToken cancellationToken) { async Task>> ClientMethod() { - List apiResponse = await this.EstateReportingApiClient.GetTopBottomOperatorData(accessToken, estateId, topBottom, resultCount, cancellationToken); - - return ModelFactory.ConvertFrom(apiResponse); + Result> apiResponse = await this.EstateReportingApiClient.GetTopBottomOperatorData(accessToken, estateId, topBottom, resultCount, cancellationToken); + if (apiResponse.IsFailed) + return ResultHelpers.CreateFailure(apiResponse); + return ModelFactory.ConvertFrom(apiResponse.Data); } return await this.CallClientMethod(ClientMethod, cancellationToken); @@ -427,9 +433,10 @@ public async Task>> GetTopBottomMerchant Int32 resultCount, CancellationToken cancellationToken) { async Task>> ClientMethod() { - List apiResponse = await this.EstateReportingApiClient.GetTopBottomMerchantData(accessToken, estateId, topBottom, resultCount, cancellationToken); - - return ModelFactory.ConvertFrom(apiResponse); + Result> apiResponse = await this.EstateReportingApiClient.GetTopBottomMerchantData(accessToken, estateId, topBottom, resultCount, cancellationToken); + if (apiResponse.IsFailed) + return ResultHelpers.CreateFailure(apiResponse); + return ModelFactory.ConvertFrom(apiResponse.Data); } return await this.CallClientMethod(ClientMethod, cancellationToken); @@ -441,9 +448,10 @@ public async Task>> GetTopBottomProductDa Int32 resultCount, CancellationToken cancellationToken) { async Task>> ClientMethod() { - List apiResponse = await this.EstateReportingApiClient.GetTopBottomProductData(accessToken, estateId, topBottom, resultCount, cancellationToken); - - return ModelFactory.ConvertFrom(apiResponse); + Result> apiResponse = await this.EstateReportingApiClient.GetTopBottomProductData(accessToken, estateId, topBottom, resultCount, cancellationToken); + if (apiResponse.IsFailed) + return ResultHelpers.CreateFailure(apiResponse); + return ModelFactory.ConvertFrom(apiResponse.Data); } return await this.CallClientMethod(ClientMethod, cancellationToken); @@ -453,9 +461,10 @@ public async Task> GetMerchantKpi(String accessToken, Guid estateId, CancellationToken cancellationToken) { async Task> ClientMethod() { - MerchantKpi apiResponse = await this.EstateReportingApiClient.GetMerchantKpi(accessToken, estateId, cancellationToken); - - return ModelFactory.ConvertFrom(apiResponse); + Result apiResponse = await this.EstateReportingApiClient.GetMerchantKpi(accessToken, estateId, cancellationToken); + if (apiResponse.IsFailed) + return ResultHelpers.CreateFailure(apiResponse); + return ModelFactory.ConvertFrom(apiResponse.Data); } return await this.CallClientMethod(ClientMethod, cancellationToken); @@ -474,9 +483,10 @@ public async Task> GetLastSettlement(String accessTo Int32? operatorReportingId, CancellationToken cancellationToken) { async Task> ClientMethod() { - LastSettlement apiResponse = await this.EstateReportingApiClient.GetLastSettlement(accessToken, estateId, cancellationToken); - - return ModelFactory.ConvertFrom(apiResponse); + Result apiResponse = await this.EstateReportingApiClient.GetLastSettlement(accessToken, estateId, cancellationToken); + if (apiResponse.IsFailed) + return ResultHelpers.CreateFailure(apiResponse); + return ModelFactory.ConvertFrom(apiResponse.Data); } return await this.CallClientMethod(ClientMethod, cancellationToken); diff --git a/EstateManagementUI.BusinessLogic/EstateManagementUI.BusinessLogic.csproj b/EstateManagementUI.BusinessLogic/EstateManagementUI.BusinessLogic.csproj index 5a14f5e6..1d81d1a2 100644 --- a/EstateManagementUI.BusinessLogic/EstateManagementUI.BusinessLogic.csproj +++ b/EstateManagementUI.BusinessLogic/EstateManagementUI.BusinessLogic.csproj @@ -1,28 +1,28 @@  - net8.0 + net9.0 enable enable - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + - - + + diff --git a/EstateManagementUI.BusinessLogic/PermissionService/PermissionsService.cs b/EstateManagementUI.BusinessLogic/PermissionService/PermissionsService.cs index b8899394..06cd2cb8 100644 --- a/EstateManagementUI.BusinessLogic/PermissionService/PermissionsService.cs +++ b/EstateManagementUI.BusinessLogic/PermissionService/PermissionsService.cs @@ -86,8 +86,18 @@ public PermissionsService(IPermissionsRepository permissionsRepository, IConfigu private async Task LoadPermissionsData() { // TODO: this will be cached and probably refreshed periodically - this.RoleFunctions = await this.PermissionsRepository.GetRolesFunctions(); - this.UserRoles= await this.PermissionsRepository.GetUsers(CancellationToken.None); + var roleResult = await this.PermissionsRepository.GetRolesFunctions(); + if (roleResult.IsFailed) { + // TODO : Handle error properly, e.g., log it or throw an exception + } + var userResult = await this.PermissionsRepository.GetUsers(CancellationToken.None); + if (userResult.IsFailed) + { + // TODO : Handle error properly, e.g., log it or throw an exception + } + + this.RoleFunctions = roleResult.Data; + this.UserRoles= userResult.Data; } private List<(String role, String section, String function)> RoleFunctions = new(); diff --git a/EstateManagementUI.BusinessLogic/RequestHandlers/ContractRequestHandler.cs b/EstateManagementUI.BusinessLogic/RequestHandlers/ContractRequestHandler.cs index 4ba7d63a..8354801f 100644 --- a/EstateManagementUI.BusinessLogic/RequestHandlers/ContractRequestHandler.cs +++ b/EstateManagementUI.BusinessLogic/RequestHandlers/ContractRequestHandler.cs @@ -6,7 +6,7 @@ namespace EstateManagementUI.BusinessLogic.RequestHandlers; -public class ContractRequestHandler : IRequestHandler>, +public class ContractRequestHandler : IRequestHandler>>, IRequestHandler>, IRequestHandler, IRequestHandler, @@ -18,15 +18,15 @@ public ContractRequestHandler(IApiClient apiClient) this.ApiClient = apiClient; } - public async Task> Handle(Queries.GetContractsQuery request, - CancellationToken cancellationToken) { - List models = await this.ApiClient.GetContracts(request.AccessToken, Guid.Empty, request.EstateId, cancellationToken); + public async Task>> Handle(Queries.GetContractsQuery request, + CancellationToken cancellationToken) { + Result> models = await this.ApiClient.GetContracts(request.AccessToken, Guid.Empty, request.EstateId, cancellationToken); return models; } public async Task> Handle(Queries.GetContractQuery request, CancellationToken cancellationToken) { - ContractModel model = await this.ApiClient.GetContract(request.AccessToken, Guid.Empty, request.EstateId, request.ContractId, cancellationToken); + Result model = await this.ApiClient.GetContract(request.AccessToken, Guid.Empty, request.EstateId, request.ContractId, cancellationToken); return model; } diff --git a/EstateManagementUI.BusinessLogic/RequestHandlers/EstateRequestHandler.cs b/EstateManagementUI.BusinessLogic/RequestHandlers/EstateRequestHandler.cs index cdbe4d9c..30a36d8e 100644 --- a/EstateManagementUI.BusinessLogic/RequestHandlers/EstateRequestHandler.cs +++ b/EstateManagementUI.BusinessLogic/RequestHandlers/EstateRequestHandler.cs @@ -2,10 +2,11 @@ using EstateManagementUI.BusinessLogic.Models; using EstateManagmentUI.BusinessLogic.Requests; using MediatR; +using SimpleResults; namespace EstateManagementUI.BusinessLogic.RequestHandlers { - public class EstateRequestHandler : IRequestHandler + public class EstateRequestHandler : IRequestHandler> { private readonly IApiClient ApiClient; @@ -13,9 +14,9 @@ public EstateRequestHandler(IApiClient apiClient) { this.ApiClient = apiClient; } - public async Task Handle(Queries.GetEstateQuery request, + public async Task> Handle(Queries.GetEstateQuery request, CancellationToken cancellationToken) { - EstateModel model = await this.ApiClient.GetEstate(request.AccessToken, Guid.Empty, request.EstateId, cancellationToken); + Result model = await this.ApiClient.GetEstate(request.AccessToken, Guid.Empty, request.EstateId, cancellationToken); return model; } } diff --git a/EstateManagementUI.BusinessLogic/Requests/Queries.cs b/EstateManagementUI.BusinessLogic/Requests/Queries.cs index 2ba6821b..cd5270b6 100644 --- a/EstateManagementUI.BusinessLogic/Requests/Queries.cs +++ b/EstateManagementUI.BusinessLogic/Requests/Queries.cs @@ -13,10 +13,10 @@ namespace EstateManagmentUI.BusinessLogic.Requests { [ExcludeFromCodeCoverage] public record Queries { - public record GetEstateQuery(String AccessToken, Guid EstateId) : IRequest; + public record GetEstateQuery(String AccessToken, Guid EstateId) : IRequest>; public record GetMerchantsQuery(String AccessToken, Guid EstateId) : IRequest>>; public record GetOperatorsQuery(String AccessToken, Guid EstateId) : IRequest>>; - public record GetContractsQuery(String AccessToken, Guid EstateId) : IRequest>; + public record GetContractsQuery(String AccessToken, Guid EstateId) : IRequest>>; public record GetOperatorQuery(String AccessToken, Guid EstateId, Guid OperatorId) : IRequest>; public record GetContractQuery(String AccessToken, Guid EstateId, Guid ContractId) : IRequest>; public record GetFileImportLogsListQuery(String AccessToken, Guid EstateId, Guid MerchantId, DateTime StartDate, DateTime EndDate) diff --git a/EstateManagementUI.IntegrationTests/Common/DockerHelper.cs b/EstateManagementUI.IntegrationTests/Common/DockerHelper.cs index 9b41a3a4..1a11df53 100644 --- a/EstateManagementUI.IntegrationTests/Common/DockerHelper.cs +++ b/EstateManagementUI.IntegrationTests/Common/DockerHelper.cs @@ -371,7 +371,11 @@ public override ContainerBuilder SetupSecurityServiceContainer() environmentVariables.Add($"ServiceOptions:PasswordOptions:RequireUpperCase=false"); environmentVariables.Add($"ServiceOptions:UserOptions:RequireUniqueEmail=false"); environmentVariables.Add($"ServiceOptions:SignInOptions:RequireConfirmedEmail=false"); - + + environmentVariables.Add(this.SetConnectionString("ConnectionStrings:PersistedGrantDbContext", $"PersistedGrantStore-{this.TestId}", this.UseSecureSqlServerDatabase)); + environmentVariables.Add(this.SetConnectionString("ConnectionStrings:ConfigurationDbContext", $"Configuration-{this.TestId}", this.UseSecureSqlServerDatabase)); + environmentVariables.Add(this.SetConnectionString("ConnectionStrings:AuthenticationDbContext", $"Authentication-{this.TestId}", this.UseSecureSqlServerDatabase)); + environmentVariables.Add("Logging:LogLevel:Microsoft=Information"); environmentVariables.Add("Logging:LogLevel:Default=Information"); environmentVariables.Add("Logging:EventLog:LogLevel:Default=None"); diff --git a/EstateManagementUI.IntegrationTests/Common/EstateManagementUiSteps.cs b/EstateManagementUI.IntegrationTests/Common/EstateManagementUiSteps.cs index fa94fc4c..b0fe9eb5 100644 --- a/EstateManagementUI.IntegrationTests/Common/EstateManagementUiSteps.cs +++ b/EstateManagementUI.IntegrationTests/Common/EstateManagementUiSteps.cs @@ -31,6 +31,8 @@ private void VerifyPageTitle(String expectedTitle) { public void NavigateToHomePage(){ this.WebDriver.Navigate().GoToUrl($"https://localhost:{this.EstateManagementUiPort}"); + // Reapply size in headless mode + this.WebDriver.Manage().Window.Size = new System.Drawing.Size(1920, 1080); this.VerifyPageTitle("Welcome"); } diff --git a/EstateManagementUI.IntegrationTests/Common/Extensions.cs b/EstateManagementUI.IntegrationTests/Common/Extensions.cs index 7a8c1054..d5523c06 100644 --- a/EstateManagementUI.IntegrationTests/Common/Extensions.cs +++ b/EstateManagementUI.IntegrationTests/Common/Extensions.cs @@ -8,6 +8,8 @@ using System.Linq; using System.Threading.Tasks; using System.Xml.Linq; +using OpenQA.Selenium.Support.Extensions; +using TransactionProcessor.Database.Entities.Summary; namespace EstateManagementUI.IntegrationTests.Common { @@ -161,12 +163,12 @@ await Retry.For(async () => { public static async Task ClickButtonById(this IWebDriver webDriver, String buttonId) { await Retry.For(async () => { - IWebElement webElement = await webDriver.FindButtonById(buttonId); - webElement.ShouldNotBeNull(); - webElement.Displayed.ShouldBe(true); - webElement.Enabled.ShouldBe(true); - webElement.Click(); - }); + IWebElement webElement = await webDriver.FindButtonById(buttonId); + webElement.ShouldNotBeNull(); + webElement.Displayed.ShouldBe(true); + webElement.Enabled.ShouldBe(true); + webElement.Click(); + }); } public static async Task ClickButtonByText(this IWebDriver webDriver, diff --git a/EstateManagementUI.IntegrationTests/Common/Hooks.cs b/EstateManagementUI.IntegrationTests/Common/Hooks.cs index 9e9507cc..b89687a6 100644 --- a/EstateManagementUI.IntegrationTests/Common/Hooks.cs +++ b/EstateManagementUI.IntegrationTests/Common/Hooks.cs @@ -1,4 +1,5 @@ using System.Diagnostics.Contracts; +using System.Drawing; using OpenQA.Selenium; using OpenQA.Selenium.Chrome; using OpenQA.Selenium.Edge; @@ -48,7 +49,7 @@ private async Task CreateWebDriver(){ String? browser = Environment.GetEnvironmentVariable("Browser"); String? isCi = Environment.GetEnvironmentVariable("IsCI"); - + //isCi = "true"; //browser = "Edge"; switch (browser) { @@ -64,9 +65,10 @@ private async Task CreateWebDriver(){ .WithDisableGpu() .WithDisableInfobars() .WithHeadless(isCi) - .WithWindowSize(1280, 1024); - + .WithWindowSize(1920, 1080); + webDriver = new ChromeDriver(options); + break; } case "Firefox": @@ -82,19 +84,17 @@ await Retry.For(async () => }, TimeSpan.FromMinutes(5), TimeSpan.FromSeconds(60)); break; } - case "Edge": - { + case "Edge": { EdgeOptions options = new EdgeOptions(); options = options.WithAcceptInsecureCertificate() - .WithHeadless(isCi) - .WithWindowSize(1280, 1024); - await Retry.For(async () => - { - webDriver = new EdgeDriver(options); - }, TimeSpan.FromMinutes(5), TimeSpan.FromSeconds(60)); + .WithHeadless(isCi) + .WithWindowSize(1920, 1080); + + await Retry.For(async () => { webDriver = new EdgeDriver(options); }, TimeSpan.FromMinutes(5), TimeSpan.FromSeconds(60)); break; } } + return webDriver; } } @@ -199,7 +199,7 @@ public static EdgeOptions WithHeadless(this EdgeOptions options, String isCi) [Pure] public static EdgeOptions WithWindowSize(this EdgeOptions options, Int32 height, Int32 width) { - String windowSize = $"--window-size={height}x{width}"; + String windowSize = $"--window-size={height},{width}"; options.AddArguments(windowSize); return options; } diff --git a/EstateManagementUI.IntegrationTests/Common/SharedSteps.cs b/EstateManagementUI.IntegrationTests/Common/SharedSteps.cs index 30e0c31d..e3ab3113 100644 --- a/EstateManagementUI.IntegrationTests/Common/SharedSteps.cs +++ b/EstateManagementUI.IntegrationTests/Common/SharedSteps.cs @@ -177,7 +177,7 @@ await Retry.For(async () => String databaseName = $"EstateReportingReadModel{verifiedEstate.EstateId}"; var connString = Setup.GetLocalConnectionString(databaseName); connString = $"{connString};Encrypt=false"; - var ctx = new EstateManagementSqlServerContext(connString); + var ctx = new EstateManagementContext(connString); var estates = ctx.Estates.ToList(); estates.Count.ShouldBe(1); @@ -246,7 +246,7 @@ public async Task WhenICreateTheFollowingMerchants(DataTable table) { List<(EstateDetails estate, CreateMerchantRequest)> requests = table.Rows.ToCreateMerchantRequests(this.TestingContext.Estates); - var verifiedMerchants = await this.TransactionProcessorSteps.WhenICreateTheFollowingMerchants(this.TestingContext.AccessToken, requests); + List verifiedMerchants = await this.TransactionProcessorSteps.WhenICreateTheFollowingMerchants(this.TestingContext.AccessToken, requests); foreach (MerchantResponse verifiedMerchant in verifiedMerchants) { @@ -292,9 +292,12 @@ private async Task CreateIdentityResource(CreateIdentityResourceRequest createId { CreateIdentityResourceResponse createIdentityResourceResponse = null; - List identityResourceList = await this.TestingContext.DockerHelper.SecurityServiceClient.GetIdentityResources(cancellationToken); - - if (identityResourceList == null || identityResourceList.Any() == false) + Result> identityResourceList = await this.TestingContext.DockerHelper.SecurityServiceClient.GetIdentityResources(cancellationToken); + if (identityResourceList.IsFailed) + { + // TODO: Handle error properly, e.g., show a message to the user + } + if (identityResourceList.Data == null || identityResourceList.Data.Any() == false) { Result result= await this .TestingContext.DockerHelper.SecurityServiceClient @@ -306,7 +309,7 @@ private async Task CreateIdentityResource(CreateIdentityResourceRequest createId } else { - if (identityResourceList.Any(i => i.Name == createIdentityResourceRequest.Name)) + if (identityResourceList.Data.Any(i => i.Name == createIdentityResourceRequest.Name)) { return; } diff --git a/EstateManagementUI.IntegrationTests/EstateManagementUI.IntegrationTests.csproj b/EstateManagementUI.IntegrationTests/EstateManagementUI.IntegrationTests.csproj index 16ba26e5..370d3976 100644 --- a/EstateManagementUI.IntegrationTests/EstateManagementUI.IntegrationTests.csproj +++ b/EstateManagementUI.IntegrationTests/EstateManagementUI.IntegrationTests.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable @@ -27,29 +27,29 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - + + + + + - - + + - - - + + + - + - + - + - + diff --git a/EstateManagementUI.IntegrationTests/Tests/ContractTests.feature.cs b/EstateManagementUI.IntegrationTests/Tests/ContractTests.feature.cs index 2ccfa8ae..48b77ba3 100644 --- a/EstateManagementUI.IntegrationTests/Tests/ContractTests.feature.cs +++ b/EstateManagementUI.IntegrationTests/Tests/ContractTests.feature.cs @@ -10,15 +10,13 @@ // ------------------------------------------------------------------------------ #region Designer generated code #pragma warning disable +using Reqnroll; namespace EstateManagementUI.IntegrationTests.Tests { - using Reqnroll; - using System; - using System.Linq; - [System.CodeDom.Compiler.GeneratedCodeAttribute("Reqnroll", "2.0.0.0")] - [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Reqnroll", "2.0.0.0")] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [NUnit.Framework.TestFixtureAttribute()] [NUnit.Framework.DescriptionAttribute("Contract Tests")] [NUnit.Framework.FixtureLifeCycleAttribute(NUnit.Framework.LifeCycle.InstancePerTestCase)] @@ -35,41 +33,63 @@ public partial class ContractTestsFeature "shared", "uigeneral"}; - private static global::Reqnroll.FeatureInfo featureInfo = new global::Reqnroll.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Tests", "Contract Tests", null, global::Reqnroll.ProgrammingLanguage.CSharp, featureTags); + private static global::Reqnroll.FeatureInfo featureInfo = new global::Reqnroll.FeatureInfo(new global::System.Globalization.CultureInfo("en-US"), "Tests", "Contract Tests", null, global::Reqnroll.ProgrammingLanguage.CSharp, featureTags); #line 1 "ContractTests.feature" #line hidden [NUnit.Framework.OneTimeSetUpAttribute()] - public static async System.Threading.Tasks.Task FeatureSetupAsync() + public static async global::System.Threading.Tasks.Task FeatureSetupAsync() { } [NUnit.Framework.OneTimeTearDownAttribute()] - public static async System.Threading.Tasks.Task FeatureTearDownAsync() + public static async global::System.Threading.Tasks.Task FeatureTearDownAsync() { } [NUnit.Framework.SetUpAttribute()] - public async System.Threading.Tasks.Task TestInitializeAsync() + public async global::System.Threading.Tasks.Task TestInitializeAsync() { testRunner = global::Reqnroll.TestRunnerManager.GetTestRunnerForAssembly(featureHint: featureInfo); - if (((testRunner.FeatureContext != null) - && (testRunner.FeatureContext.FeatureInfo.Equals(featureInfo) == false))) + try { - await testRunner.OnFeatureEndAsync(); + if (((testRunner.FeatureContext != null) + && (testRunner.FeatureContext.FeatureInfo.Equals(featureInfo) == false))) + { + await testRunner.OnFeatureEndAsync(); + } } - if ((testRunner.FeatureContext == null)) + finally { - await testRunner.OnFeatureStartAsync(featureInfo); + if (((testRunner.FeatureContext != null) + && testRunner.FeatureContext.BeforeFeatureHookFailed)) + { + throw new global::Reqnroll.ReqnrollException("Scenario skipped because of previous before feature hook error"); + } + if ((testRunner.FeatureContext == null)) + { + await testRunner.OnFeatureStartAsync(featureInfo); + } } } [NUnit.Framework.TearDownAttribute()] - public async System.Threading.Tasks.Task TestTearDownAsync() + public async global::System.Threading.Tasks.Task TestTearDownAsync() { - await testRunner.OnScenarioEndAsync(); - global::Reqnroll.TestRunnerManager.ReleaseTestRunner(testRunner); + if ((testRunner == null)) + { + return; + } + try + { + await testRunner.OnScenarioEndAsync(); + } + finally + { + global::Reqnroll.TestRunnerManager.ReleaseTestRunner(testRunner); + testRunner = null; + } } public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo) @@ -78,17 +98,17 @@ public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo) testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); } - public async System.Threading.Tasks.Task ScenarioStartAsync() + public async global::System.Threading.Tasks.Task ScenarioStartAsync() { await testRunner.OnScenarioStartAsync(); } - public async System.Threading.Tasks.Task ScenarioCleanupAsync() + public async global::System.Threading.Tasks.Task ScenarioCleanupAsync() { await testRunner.CollectScenarioErrorsAsync(); } - public virtual async System.Threading.Tasks.Task FeatureBackgroundAsync() + public virtual async global::System.Threading.Tasks.Task FeatureBackgroundAsync() { #line 4 #line hidden @@ -357,11 +377,11 @@ public virtual async System.Threading.Tasks.Task FeatureBackgroundAsync() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Contract PR Test")] [NUnit.Framework.CategoryAttribute("PRTest")] - public async System.Threading.Tasks.Task ContractPRTest() + public async global::System.Threading.Tasks.Task ContractPRTest() { string[] tagsOfScenario = new string[] { "PRTest"}; - System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Contract PR Test", null, tagsOfScenario, argumentsOfScenario, featureTags); #line 81 this.ScenarioInitialize(scenarioInfo); diff --git a/EstateManagementUI.IntegrationTests/Tests/EstateTests.feature.cs b/EstateManagementUI.IntegrationTests/Tests/EstateTests.feature.cs index 1d7220ff..29cfc445 100644 --- a/EstateManagementUI.IntegrationTests/Tests/EstateTests.feature.cs +++ b/EstateManagementUI.IntegrationTests/Tests/EstateTests.feature.cs @@ -10,15 +10,13 @@ // ------------------------------------------------------------------------------ #region Designer generated code #pragma warning disable +using Reqnroll; namespace EstateManagementUI.IntegrationTests.Tests { - using Reqnroll; - using System; - using System.Linq; - [System.CodeDom.Compiler.GeneratedCodeAttribute("Reqnroll", "2.0.0.0")] - [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Reqnroll", "2.0.0.0")] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [NUnit.Framework.TestFixtureAttribute()] [NUnit.Framework.DescriptionAttribute("Estate Tests")] [NUnit.Framework.FixtureLifeCycleAttribute(NUnit.Framework.LifeCycle.InstancePerTestCase)] @@ -35,41 +33,63 @@ public partial class EstateTestsFeature "shared", "uigeneral"}; - private static global::Reqnroll.FeatureInfo featureInfo = new global::Reqnroll.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Tests", "Estate Tests", null, global::Reqnroll.ProgrammingLanguage.CSharp, featureTags); + private static global::Reqnroll.FeatureInfo featureInfo = new global::Reqnroll.FeatureInfo(new global::System.Globalization.CultureInfo("en-US"), "Tests", "Estate Tests", null, global::Reqnroll.ProgrammingLanguage.CSharp, featureTags); #line 1 "EstateTests.feature" #line hidden [NUnit.Framework.OneTimeSetUpAttribute()] - public static async System.Threading.Tasks.Task FeatureSetupAsync() + public static async global::System.Threading.Tasks.Task FeatureSetupAsync() { } [NUnit.Framework.OneTimeTearDownAttribute()] - public static async System.Threading.Tasks.Task FeatureTearDownAsync() + public static async global::System.Threading.Tasks.Task FeatureTearDownAsync() { } [NUnit.Framework.SetUpAttribute()] - public async System.Threading.Tasks.Task TestInitializeAsync() + public async global::System.Threading.Tasks.Task TestInitializeAsync() { testRunner = global::Reqnroll.TestRunnerManager.GetTestRunnerForAssembly(featureHint: featureInfo); - if (((testRunner.FeatureContext != null) - && (testRunner.FeatureContext.FeatureInfo.Equals(featureInfo) == false))) + try { - await testRunner.OnFeatureEndAsync(); + if (((testRunner.FeatureContext != null) + && (testRunner.FeatureContext.FeatureInfo.Equals(featureInfo) == false))) + { + await testRunner.OnFeatureEndAsync(); + } } - if ((testRunner.FeatureContext == null)) + finally { - await testRunner.OnFeatureStartAsync(featureInfo); + if (((testRunner.FeatureContext != null) + && testRunner.FeatureContext.BeforeFeatureHookFailed)) + { + throw new global::Reqnroll.ReqnrollException("Scenario skipped because of previous before feature hook error"); + } + if ((testRunner.FeatureContext == null)) + { + await testRunner.OnFeatureStartAsync(featureInfo); + } } } [NUnit.Framework.TearDownAttribute()] - public async System.Threading.Tasks.Task TestTearDownAsync() + public async global::System.Threading.Tasks.Task TestTearDownAsync() { - await testRunner.OnScenarioEndAsync(); - global::Reqnroll.TestRunnerManager.ReleaseTestRunner(testRunner); + if ((testRunner == null)) + { + return; + } + try + { + await testRunner.OnScenarioEndAsync(); + } + finally + { + global::Reqnroll.TestRunnerManager.ReleaseTestRunner(testRunner); + testRunner = null; + } } public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo) @@ -78,17 +98,17 @@ public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo) testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); } - public async System.Threading.Tasks.Task ScenarioStartAsync() + public async global::System.Threading.Tasks.Task ScenarioStartAsync() { await testRunner.OnScenarioStartAsync(); } - public async System.Threading.Tasks.Task ScenarioCleanupAsync() + public async global::System.Threading.Tasks.Task ScenarioCleanupAsync() { await testRunner.CollectScenarioErrorsAsync(); } - public virtual async System.Threading.Tasks.Task FeatureBackgroundAsync() + public virtual async global::System.Threading.Tasks.Task FeatureBackgroundAsync() { #line 4 #line hidden @@ -259,10 +279,10 @@ public virtual async System.Threading.Tasks.Task FeatureBackgroundAsync() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("I Can Log Into The Application")] - public async System.Threading.Tasks.Task ICanLogIntoTheApplication() + public async global::System.Threading.Tasks.Task ICanLogIntoTheApplication() { string[] tagsOfScenario = ((string[])(null)); - System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("I Can Log Into The Application", null, tagsOfScenario, argumentsOfScenario, featureTags); #line 54 this.ScenarioInitialize(scenarioInfo); @@ -299,11 +319,11 @@ public async System.Threading.Tasks.Task ICanLogIntoTheApplication() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("View Estate Details")] [NUnit.Framework.CategoryAttribute("PRTest")] - public async System.Threading.Tasks.Task ViewEstateDetails() + public async global::System.Threading.Tasks.Task ViewEstateDetails() { string[] tagsOfScenario = new string[] { "PRTest"}; - System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("View Estate Details", null, tagsOfScenario, argumentsOfScenario, featureTags); #line 67 this.ScenarioInitialize(scenarioInfo); diff --git a/EstateManagementUI.IntegrationTests/Tests/MerchantTests.feature.cs b/EstateManagementUI.IntegrationTests/Tests/MerchantTests.feature.cs index 6f49a6a7..b447063c 100644 --- a/EstateManagementUI.IntegrationTests/Tests/MerchantTests.feature.cs +++ b/EstateManagementUI.IntegrationTests/Tests/MerchantTests.feature.cs @@ -10,15 +10,13 @@ // ------------------------------------------------------------------------------ #region Designer generated code #pragma warning disable +using Reqnroll; namespace EstateManagementUI.IntegrationTests.Tests { - using Reqnroll; - using System; - using System.Linq; - [System.CodeDom.Compiler.GeneratedCodeAttribute("Reqnroll", "2.0.0.0")] - [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Reqnroll", "2.0.0.0")] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [NUnit.Framework.TestFixtureAttribute()] [NUnit.Framework.DescriptionAttribute("Merchant Tests")] [NUnit.Framework.FixtureLifeCycleAttribute(NUnit.Framework.LifeCycle.InstancePerTestCase)] @@ -35,41 +33,63 @@ public partial class MerchantTestsFeature "shared", "uigeneral"}; - private static global::Reqnroll.FeatureInfo featureInfo = new global::Reqnroll.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Tests", "Merchant Tests", null, global::Reqnroll.ProgrammingLanguage.CSharp, featureTags); + private static global::Reqnroll.FeatureInfo featureInfo = new global::Reqnroll.FeatureInfo(new global::System.Globalization.CultureInfo("en-US"), "Tests", "Merchant Tests", null, global::Reqnroll.ProgrammingLanguage.CSharp, featureTags); #line 1 "MerchantTests.feature" #line hidden [NUnit.Framework.OneTimeSetUpAttribute()] - public static async System.Threading.Tasks.Task FeatureSetupAsync() + public static async global::System.Threading.Tasks.Task FeatureSetupAsync() { } [NUnit.Framework.OneTimeTearDownAttribute()] - public static async System.Threading.Tasks.Task FeatureTearDownAsync() + public static async global::System.Threading.Tasks.Task FeatureTearDownAsync() { } [NUnit.Framework.SetUpAttribute()] - public async System.Threading.Tasks.Task TestInitializeAsync() + public async global::System.Threading.Tasks.Task TestInitializeAsync() { testRunner = global::Reqnroll.TestRunnerManager.GetTestRunnerForAssembly(featureHint: featureInfo); - if (((testRunner.FeatureContext != null) - && (testRunner.FeatureContext.FeatureInfo.Equals(featureInfo) == false))) + try { - await testRunner.OnFeatureEndAsync(); + if (((testRunner.FeatureContext != null) + && (testRunner.FeatureContext.FeatureInfo.Equals(featureInfo) == false))) + { + await testRunner.OnFeatureEndAsync(); + } } - if ((testRunner.FeatureContext == null)) + finally { - await testRunner.OnFeatureStartAsync(featureInfo); + if (((testRunner.FeatureContext != null) + && testRunner.FeatureContext.BeforeFeatureHookFailed)) + { + throw new global::Reqnroll.ReqnrollException("Scenario skipped because of previous before feature hook error"); + } + if ((testRunner.FeatureContext == null)) + { + await testRunner.OnFeatureStartAsync(featureInfo); + } } } [NUnit.Framework.TearDownAttribute()] - public async System.Threading.Tasks.Task TestTearDownAsync() + public async global::System.Threading.Tasks.Task TestTearDownAsync() { - await testRunner.OnScenarioEndAsync(); - global::Reqnroll.TestRunnerManager.ReleaseTestRunner(testRunner); + if ((testRunner == null)) + { + return; + } + try + { + await testRunner.OnScenarioEndAsync(); + } + finally + { + global::Reqnroll.TestRunnerManager.ReleaseTestRunner(testRunner); + testRunner = null; + } } public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo) @@ -78,17 +98,17 @@ public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo) testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); } - public async System.Threading.Tasks.Task ScenarioStartAsync() + public async global::System.Threading.Tasks.Task ScenarioStartAsync() { await testRunner.OnScenarioStartAsync(); } - public async System.Threading.Tasks.Task ScenarioCleanupAsync() + public async global::System.Threading.Tasks.Task ScenarioCleanupAsync() { await testRunner.CollectScenarioErrorsAsync(); } - public virtual async System.Threading.Tasks.Task FeatureBackgroundAsync() + public virtual async global::System.Threading.Tasks.Task FeatureBackgroundAsync() { #line 4 #line hidden @@ -393,11 +413,11 @@ public virtual async System.Threading.Tasks.Task FeatureBackgroundAsync() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Merchant PR Test")] [NUnit.Framework.CategoryAttribute("PRTest")] - public async System.Threading.Tasks.Task MerchantPRTest() + public async global::System.Threading.Tasks.Task MerchantPRTest() { string[] tagsOfScenario = new string[] { "PRTest"}; - System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Merchant PR Test", null, tagsOfScenario, argumentsOfScenario, featureTags); #line 88 this.ScenarioInitialize(scenarioInfo); @@ -610,10 +630,10 @@ public async System.Threading.Tasks.Task MerchantPRTest() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Merchant Operator Management")] - public async System.Threading.Tasks.Task MerchantOperatorManagement() + public async global::System.Threading.Tasks.Task MerchantOperatorManagement() { string[] tagsOfScenario = ((string[])(null)); - System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Merchant Operator Management", null, tagsOfScenario, argumentsOfScenario, featureTags); #line 136 this.ScenarioInitialize(scenarioInfo); @@ -777,10 +797,10 @@ public async System.Threading.Tasks.Task MerchantOperatorManagement() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Merchant Contract Management")] - public async System.Threading.Tasks.Task MerchantContractManagement() + public async global::System.Threading.Tasks.Task MerchantContractManagement() { string[] tagsOfScenario = ((string[])(null)); - System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Merchant Contract Management", null, tagsOfScenario, argumentsOfScenario, featureTags); #line 179 this.ScenarioInitialize(scenarioInfo); @@ -928,10 +948,10 @@ public async System.Threading.Tasks.Task MerchantContractManagement() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Merchant Device Management")] - public async System.Threading.Tasks.Task MerchantDeviceManagement() + public async global::System.Threading.Tasks.Task MerchantDeviceManagement() { string[] tagsOfScenario = ((string[])(null)); - System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Merchant Device Management", null, tagsOfScenario, argumentsOfScenario, featureTags); #line 227 this.ScenarioInitialize(scenarioInfo); diff --git a/EstateManagementUI.IntegrationTests/Tests/OperatorTests.feature.cs b/EstateManagementUI.IntegrationTests/Tests/OperatorTests.feature.cs index 01bbdea4..78a78464 100644 --- a/EstateManagementUI.IntegrationTests/Tests/OperatorTests.feature.cs +++ b/EstateManagementUI.IntegrationTests/Tests/OperatorTests.feature.cs @@ -10,15 +10,13 @@ // ------------------------------------------------------------------------------ #region Designer generated code #pragma warning disable +using Reqnroll; namespace EstateManagementUI.IntegrationTests.Tests { - using Reqnroll; - using System; - using System.Linq; - [System.CodeDom.Compiler.GeneratedCodeAttribute("Reqnroll", "2.0.0.0")] - [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Reqnroll", "2.0.0.0")] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [NUnit.Framework.TestFixtureAttribute()] [NUnit.Framework.DescriptionAttribute("Operator Tests")] [NUnit.Framework.FixtureLifeCycleAttribute(NUnit.Framework.LifeCycle.InstancePerTestCase)] @@ -35,41 +33,63 @@ public partial class OperatorTestsFeature "shared", "uigeneral"}; - private static global::Reqnroll.FeatureInfo featureInfo = new global::Reqnroll.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Tests", "Operator Tests", null, global::Reqnroll.ProgrammingLanguage.CSharp, featureTags); + private static global::Reqnroll.FeatureInfo featureInfo = new global::Reqnroll.FeatureInfo(new global::System.Globalization.CultureInfo("en-US"), "Tests", "Operator Tests", null, global::Reqnroll.ProgrammingLanguage.CSharp, featureTags); #line 1 "OperatorTests.feature" #line hidden [NUnit.Framework.OneTimeSetUpAttribute()] - public static async System.Threading.Tasks.Task FeatureSetupAsync() + public static async global::System.Threading.Tasks.Task FeatureSetupAsync() { } [NUnit.Framework.OneTimeTearDownAttribute()] - public static async System.Threading.Tasks.Task FeatureTearDownAsync() + public static async global::System.Threading.Tasks.Task FeatureTearDownAsync() { } [NUnit.Framework.SetUpAttribute()] - public async System.Threading.Tasks.Task TestInitializeAsync() + public async global::System.Threading.Tasks.Task TestInitializeAsync() { testRunner = global::Reqnroll.TestRunnerManager.GetTestRunnerForAssembly(featureHint: featureInfo); - if (((testRunner.FeatureContext != null) - && (testRunner.FeatureContext.FeatureInfo.Equals(featureInfo) == false))) + try { - await testRunner.OnFeatureEndAsync(); + if (((testRunner.FeatureContext != null) + && (testRunner.FeatureContext.FeatureInfo.Equals(featureInfo) == false))) + { + await testRunner.OnFeatureEndAsync(); + } } - if ((testRunner.FeatureContext == null)) + finally { - await testRunner.OnFeatureStartAsync(featureInfo); + if (((testRunner.FeatureContext != null) + && testRunner.FeatureContext.BeforeFeatureHookFailed)) + { + throw new global::Reqnroll.ReqnrollException("Scenario skipped because of previous before feature hook error"); + } + if ((testRunner.FeatureContext == null)) + { + await testRunner.OnFeatureStartAsync(featureInfo); + } } } [NUnit.Framework.TearDownAttribute()] - public async System.Threading.Tasks.Task TestTearDownAsync() + public async global::System.Threading.Tasks.Task TestTearDownAsync() { - await testRunner.OnScenarioEndAsync(); - global::Reqnroll.TestRunnerManager.ReleaseTestRunner(testRunner); + if ((testRunner == null)) + { + return; + } + try + { + await testRunner.OnScenarioEndAsync(); + } + finally + { + global::Reqnroll.TestRunnerManager.ReleaseTestRunner(testRunner); + testRunner = null; + } } public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo) @@ -78,17 +98,17 @@ public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo) testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); } - public async System.Threading.Tasks.Task ScenarioStartAsync() + public async global::System.Threading.Tasks.Task ScenarioStartAsync() { await testRunner.OnScenarioStartAsync(); } - public async System.Threading.Tasks.Task ScenarioCleanupAsync() + public async global::System.Threading.Tasks.Task ScenarioCleanupAsync() { await testRunner.CollectScenarioErrorsAsync(); } - public virtual async System.Threading.Tasks.Task FeatureBackgroundAsync() + public virtual async global::System.Threading.Tasks.Task FeatureBackgroundAsync() { #line 4 #line hidden @@ -291,11 +311,11 @@ public virtual async System.Threading.Tasks.Task FeatureBackgroundAsync() [NUnit.Framework.TestAttribute()] [NUnit.Framework.DescriptionAttribute("Operator PR Test")] [NUnit.Framework.CategoryAttribute("PRTest")] - public async System.Threading.Tasks.Task OperatorPRTest() + public async global::System.Threading.Tasks.Task OperatorPRTest() { string[] tagsOfScenario = new string[] { "PRTest"}; - System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Operator PR Test", null, tagsOfScenario, argumentsOfScenario, featureTags); #line 68 this.ScenarioInitialize(scenarioInfo); diff --git a/EstateManagementUI.Testing/EstateManagementUI.Testing.csproj b/EstateManagementUI.Testing/EstateManagementUI.Testing.csproj index f6c54307..da702372 100644 --- a/EstateManagementUI.Testing/EstateManagementUI.Testing.csproj +++ b/EstateManagementUI.Testing/EstateManagementUI.Testing.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable None @@ -14,10 +14,10 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/EstateManagementUI.UITests/EstateManagementUI.UITests.csproj b/EstateManagementUI.UITests/EstateManagementUI.UITests.csproj index 5aa9db3f..6c32d436 100644 --- a/EstateManagementUI.UITests/EstateManagementUI.UITests.csproj +++ b/EstateManagementUI.UITests/EstateManagementUI.UITests.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 enable enable None @@ -10,11 +10,11 @@ - - - + + + - + diff --git a/EstateManagementUI.ViewModels/EstateManagementUI.ViewModels.csproj b/EstateManagementUI.ViewModels/EstateManagementUI.ViewModels.csproj index b60c4641..fcdb73a8 100644 --- a/EstateManagementUI.ViewModels/EstateManagementUI.ViewModels.csproj +++ b/EstateManagementUI.ViewModels/EstateManagementUI.ViewModels.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable None enable diff --git a/EstateManagementUI/Bootstrapper/MediatorRegistry.cs b/EstateManagementUI/Bootstrapper/MediatorRegistry.cs index 99ac35a5..cf4a8a35 100644 --- a/EstateManagementUI/Bootstrapper/MediatorRegistry.cs +++ b/EstateManagementUI/Bootstrapper/MediatorRegistry.cs @@ -24,7 +24,7 @@ public MediatorRegistry() { } private void RegisterEstateRequestHandler() { - this.AddSingleton, EstateRequestHandler>(); + this.AddSingleton>, EstateRequestHandler>(); } private void RegisterMerchantRequestHandler() { @@ -50,7 +50,7 @@ private void RegisterOperatorRequestHandler() { } private void RegisterContractRequestHandler() { - this.AddSingleton>, ContractRequestHandler>(); + this.AddSingleton>>, ContractRequestHandler>(); this.AddSingleton>, ContractRequestHandler>(); this.AddSingleton>, OperatorRequestHandler>(); diff --git a/EstateManagementUI/Common/DataHelperFunctions.cs b/EstateManagementUI/Common/DataHelperFunctions.cs index 4c45a003..06c2c4b5 100644 --- a/EstateManagementUI/Common/DataHelperFunctions.cs +++ b/EstateManagementUI/Common/DataHelperFunctions.cs @@ -1,9 +1,11 @@ +using EstateManagementUI.BusinessLogic.Common; using EstateManagementUI.BusinessLogic.Models; using EstateManagementUI.Pages.Components; using EstateManagementUI.ViewModels; using EstateManagmentUI.BusinessLogic.Requests; using MediatR; using Microsoft.AspNetCore.Mvc.Rendering; +using Shared.Results; using SimpleResults; using System.Globalization; using TransactionProcessor.DataTransferObjects.Responses.Contract; @@ -15,6 +17,12 @@ public static async Task GetComparisonDates(String acce Result> response = await mediator.Send(query, CancellationToken.None); + if (response.IsFailed) + { + // Handle the case where no comparison dates are found + return new ComparisonDateListModel { SelectedDate = null, Dates = new List() }; + } + List resultList = new(); IOrderedEnumerable orderedData = response.Data.OrderBy(r => r.OrderValue); @@ -118,10 +126,12 @@ public static async Task GetContracts(String accessToken, Gui { Queries.GetContractsQuery query = new(accessToken, estateId); - List response = await mediator.Send(query, CancellationToken.None); - + Result> response = await mediator.Send(query, CancellationToken.None); + if (response.IsFailed) { + // TODO: Handle error properly, e.g., show a message to the user + } List resultList = new(); - foreach (var contractModel in response) + foreach (ContractModel contractModel in response.Data) { resultList.Add(new SelectListItem { diff --git a/EstateManagementUI/Dockerfile b/EstateManagementUI/Dockerfile index b4419d34..d669c7a6 100644 --- a/EstateManagementUI/Dockerfile +++ b/EstateManagementUI/Dockerfile @@ -2,7 +2,7 @@ FROM stuartferguson/txnprocbase AS base WORKDIR /app # This stage is used to build the service project -FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["EstateManagementUI/NuGet.Config", "."] diff --git a/EstateManagementUI/EstateManagementUI.csproj b/EstateManagementUI/EstateManagementUI.csproj index 24a3a431..d3e6d194 100644 --- a/EstateManagementUI/EstateManagementUI.csproj +++ b/EstateManagementUI/EstateManagementUI.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable Regular 246afedf-f035-44d4-b568-e928505d5060 @@ -34,18 +34,18 @@ - - + + - - - - - + + + + + - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/EstateManagementUI/Pages/Contract/ContractProduct/ContractProductsList.cshtml.cs b/EstateManagementUI/Pages/Contract/ContractProduct/ContractProductsList.cshtml.cs index d4b00054..4df8fb44 100644 --- a/EstateManagementUI/Pages/Contract/ContractProduct/ContractProductsList.cshtml.cs +++ b/EstateManagementUI/Pages/Contract/ContractProduct/ContractProductsList.cshtml.cs @@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Mvc; using System.Diagnostics.Contracts; using EstateManagementUI.BusinessLogic.PermissionService; +using SimpleResults; namespace EstateManagementUI.Pages.Contract.ContractProduct { @@ -39,12 +40,15 @@ private async Task GetContract() Queries.GetContractQuery query = new Queries.GetContractQuery(this.AccessToken, this.EstateId, ContractId); - ContractModel response = await Mediator.Send(query, CancellationToken.None); + Result response = await Mediator.Send(query, CancellationToken.None); + if (response.IsFailed) { + // TODO: Handle error properly, e.g., show a message to the user + } - ContractName = response.Description; + ContractName = response.Data.Description; List resultList = new(); - foreach (ContractProductModel responseContractProduct in response.ContractProducts) + foreach (ContractProductModel responseContractProduct in response.Data.ContractProducts) { resultList.Add(new ViewModels.ContractProduct { diff --git a/EstateManagementUI/Pages/Contract/ContractProductTransactionFee/ContractProductTransactionFeeList.cshtml.cs b/EstateManagementUI/Pages/Contract/ContractProductTransactionFee/ContractProductTransactionFeeList.cshtml.cs index 1c4d4f8a..abd24a25 100644 --- a/EstateManagementUI/Pages/Contract/ContractProductTransactionFee/ContractProductTransactionFeeList.cshtml.cs +++ b/EstateManagementUI/Pages/Contract/ContractProductTransactionFee/ContractProductTransactionFeeList.cshtml.cs @@ -9,6 +9,7 @@ using MediatR; using EstateManagementUI.BusinessLogic.PermissionService.Constants; using EstateManagementUI.Pages.Merchant; +using SimpleResults; namespace EstateManagementUI.Pages.Contract.ContractProductTransactionFee { @@ -38,10 +39,13 @@ private async Task GetContract() Queries.GetContractQuery query = new Queries.GetContractQuery(this.AccessToken, this.EstateId, ContractId); - ContractModel response = await Mediator.Send(query, CancellationToken.None); - + Result response = await Mediator.Send(query, CancellationToken.None); + if (response.IsFailed) + { + // TODO: Handle error properly, e.g., show a message to the user + } ContractProductModel contractProduct = - response.ContractProducts.SingleOrDefault(cp => cp.ContractProductId == this.ContractProductId); + response.Data.ContractProducts.SingleOrDefault(cp => cp.ContractProductId == this.ContractProductId); this.ContractProductName = contractProduct.ProductName; List resultList = new(); diff --git a/EstateManagementUI/Pages/Contract/Contracts/ContractsList.cshtml.cs b/EstateManagementUI/Pages/Contract/Contracts/ContractsList.cshtml.cs index 91abfad2..f197f802 100644 --- a/EstateManagementUI/Pages/Contract/Contracts/ContractsList.cshtml.cs +++ b/EstateManagementUI/Pages/Contract/Contracts/ContractsList.cshtml.cs @@ -6,6 +6,7 @@ using EstateManagmentUI.BusinessLogic.Requests; using MediatR; using Microsoft.AspNetCore.Mvc; +using SimpleResults; namespace EstateManagementUI.Pages.Contract.Contracts { @@ -32,10 +33,13 @@ private async Task GetContracts() Queries.GetContractsQuery query = new Queries.GetContractsQuery(this.AccessToken, this.EstateId); - List response = await this.Mediator.Send(query, CancellationToken.None); - + Result> response = await this.Mediator.Send(query, CancellationToken.None); + if (response.IsFailed) + { + // TODO: Handle error properly, e.g., show a message to the user + } List resultList = new(); - foreach (ContractModel contractModel in response) + foreach (ContractModel contractModel in response.Data) { resultList.Add(new ViewModels.Contract { diff --git a/EstateManagementUI/Pages/Dashboard/Dashboard/Dashboard.cshtml.cs b/EstateManagementUI/Pages/Dashboard/Dashboard/Dashboard.cshtml.cs index 8a809c30..b00c5412 100644 --- a/EstateManagementUI/Pages/Dashboard/Dashboard/Dashboard.cshtml.cs +++ b/EstateManagementUI/Pages/Dashboard/Dashboard/Dashboard.cshtml.cs @@ -13,6 +13,7 @@ using System.Reflection.Metadata; using System; using System.Linq.Expressions; +using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; using Microsoft.Extensions.Primitives; using static EstateManagementUI.Common.ChartBuilder; @@ -48,8 +49,8 @@ public override async Task MountAsync() await this.PopulateTokenAndEstateId(); this.Merchant = await DataHelperFunctions.GetMerchants(this.AccessToken, this.EstateId, this.Mediator); - this.Operator = await DataHelperFunctions.GetOperatorsOld(this.AccessToken, this.EstateId, this.Mediator); - this.ComparisonDate = await DataHelperFunctions.GetComparisonDates(this.AccessToken, this.EstateId, this.Mediator ); + this.Operator = await DataHelperFunctions.GetOperatorsOld(this.AccessToken, this.EstateId, this.Mediator); + this.ComparisonDate = await DataHelperFunctions.GetComparisonDates(this.AccessToken, this.EstateId, this.Mediator); await this.Query(); } @@ -177,7 +178,7 @@ public async Task Query() { this.Client.ExecuteJs(ChartHelpers.GetScriptForCharts("salescountbyhourchart", ChartHelpers.ConvertChartOptionsToHtml(this.GetSalesCountByHourChart()))); } } - + private String GetSalesValueByHourChart() { List> seriesList = new List>(); List categoryList = new List(); @@ -223,10 +224,10 @@ private String GetSalesCountByHourChart() yAxisFormatFunction: StandardJavascriptFunctions.CurrencyFormatter); } - public TodaysSales TodaysSales { get; set; } - public TodaysSettlement TodaysSettlement { get; set; } - public TodaysSalesValueByHour TodaysSalesValueByHour { get; set; } - public TodaysSalesCountByHour TodaysSalesCountByHour { get; set; } + public TodaysSales TodaysSales { get; set; } = new TodaysSales(); + public TodaysSettlement TodaysSettlement { get; set; } = new TodaysSettlement(); + public TodaysSalesValueByHour TodaysSalesValueByHour { get; set; } = new TodaysSalesValueByHour { Hours = new List() }; + public TodaysSalesCountByHour TodaysSalesCountByHour { get; set; } = new TodaysSalesCountByHour{Hours = new List()}; } } \ No newline at end of file diff --git a/EstateManagementUI/Pages/Estate/OperatorList/OperatorList.cshtml.cs b/EstateManagementUI/Pages/Estate/OperatorList/OperatorList.cshtml.cs index 4c252eff..26fef3c1 100644 --- a/EstateManagementUI/Pages/Estate/OperatorList/OperatorList.cshtml.cs +++ b/EstateManagementUI/Pages/Estate/OperatorList/OperatorList.cshtml.cs @@ -8,6 +8,7 @@ using Hydro; using MediatR; using Microsoft.AspNetCore.Authentication; +using SimpleResults; namespace EstateManagementUI.Pages.Estate.OperatorList { @@ -29,9 +30,12 @@ public override async Task MountAsync() Queries.GetEstateQuery query = new Queries.GetEstateQuery(AccessToken, EstateId); - EstateModel response = await Mediator.Send(query, CancellationToken.None); - - foreach (EstateOperatorModel estateOperatorModel in response.Operators) + Result response = await Mediator.Send(query, CancellationToken.None); + if (response.IsFailed) + { + // TODO: Handle error properly, e.g., show a message to the user + } + foreach (EstateOperatorModel estateOperatorModel in response.Data.Operators) { Operators.Add(new ViewModels.Operator { diff --git a/EstateManagementUI/Pages/Estate/UsersList/UsersList.cshtml.cs b/EstateManagementUI/Pages/Estate/UsersList/UsersList.cshtml.cs index 68628569..77cff8bc 100644 --- a/EstateManagementUI/Pages/Estate/UsersList/UsersList.cshtml.cs +++ b/EstateManagementUI/Pages/Estate/UsersList/UsersList.cshtml.cs @@ -9,6 +9,7 @@ using EstateManagementUI.ViewModels; using EstateManagmentUI.BusinessLogic.Requests; using MediatR; +using SimpleResults; namespace EstateManagementUI.Pages.Estate.UsersList { @@ -30,9 +31,12 @@ public override async Task MountAsync() Queries.GetEstateQuery query = new Queries.GetEstateQuery(AccessToken, EstateId); - EstateModel response = await Mediator.Send(query, CancellationToken.None); - - foreach (SecurityUserModel securityUserModel in response.SecurityUsers) + Result response = await Mediator.Send(query, CancellationToken.None); + if (response.IsFailed) + { + // TODO: Handle error properly, e.g., show a message to the user + } + foreach (SecurityUserModel securityUserModel in response.Data.SecurityUsers) { Users.Add(new User() { diff --git a/EstateManagementUI/Pages/Estate/ViewEstate/ViewEstate.cshtml.cs b/EstateManagementUI/Pages/Estate/ViewEstate/ViewEstate.cshtml.cs index feb592f6..18bde9eb 100644 --- a/EstateManagementUI/Pages/Estate/ViewEstate/ViewEstate.cshtml.cs +++ b/EstateManagementUI/Pages/Estate/ViewEstate/ViewEstate.cshtml.cs @@ -12,6 +12,7 @@ using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using SimpleResults; using static System.Collections.Specialized.BitVector32; namespace EstateManagementUI.Pages.Estate.ViewEstate @@ -33,13 +34,16 @@ public override async Task MountAsync() Queries.GetEstateQuery query = new Queries.GetEstateQuery(AccessToken, EstateId); - EstateModel response = await Mediator.Send(query, CancellationToken.None); - + Result response = await Mediator.Send(query, CancellationToken.None); + if (response.IsFailed) + { + // TODO: Handle error properly, e.g., show a message to the user + } Estate = new ViewModels.Estate { - Name = response.EstateName, - Id = response.EstateId, - Reference = response.Reference + Name = response.Data.EstateName, + Id = response.Data.EstateId, + Reference = response.Data.Reference }; } } diff --git a/EstateManagementUI/Pages/FileProcessing/FileImportLog/FileImportLog.cshtml.cs b/EstateManagementUI/Pages/FileProcessing/FileImportLog/FileImportLog.cshtml.cs index c6e56624..202ef60e 100644 --- a/EstateManagementUI/Pages/FileProcessing/FileImportLog/FileImportLog.cshtml.cs +++ b/EstateManagementUI/Pages/FileProcessing/FileImportLog/FileImportLog.cshtml.cs @@ -38,8 +38,11 @@ private async Task GetFileImportLog() { await this.PopulateTokenAndEstateId(); Queries.GetEstateQuery estateQuery = new Queries.GetEstateQuery(this.AccessToken, this.EstateId); - EstateModel estate = await this.Mediator.Send(estateQuery); - + Result estate = await this.Mediator.Send(estateQuery); + if (estate.IsFailed) + { + // TODO: Handle error properly, e.g., show a message to the user + } Queries.GetFileImportLogQuery query = new Queries.GetFileImportLogQuery(this.AccessToken, this.EstateId, this.MerchantId, this.FileImportLogId); @@ -50,7 +53,7 @@ private async Task GetFileImportLog() { this.FileImportLogId = response.Data.FileImportLogId; List resultList = new List(); foreach (FileImportLogFileModel fileImportLogFileModel in response.Data.Files) { - SecurityUserModel user = estate.SecurityUsers.SingleOrDefault(u => u.SecurityUserId == fileImportLogFileModel.UserId); + SecurityUserModel user = estate.Data.SecurityUsers.SingleOrDefault(u => u.SecurityUserId == fileImportLogFileModel.UserId); String fileProfile = fileImportLogFileModel.FileProfileId.ToString().ToUpper() switch { "B2A59ABF-293D-4A6B-B81B-7007503C3476" => "Safaricom Topup", "8806EDBC-3ED6-406B-9E5F-A9078356BE99" => "Voucher Issue", diff --git a/EstateManagementUI/Pages/FileProcessing/FileImportLogs/FileImportLogList.cshtml.cs b/EstateManagementUI/Pages/FileProcessing/FileImportLogs/FileImportLogList.cshtml.cs index 5fc15f14..b1ff96e8 100644 --- a/EstateManagementUI/Pages/FileProcessing/FileImportLogs/FileImportLogList.cshtml.cs +++ b/EstateManagementUI/Pages/FileProcessing/FileImportLogs/FileImportLogList.cshtml.cs @@ -54,10 +54,13 @@ private async Task GetMerchants() Queries.GetMerchantsQuery query = new Queries.GetMerchantsQuery(this.AccessToken, this.EstateId); - List response = await this.Mediator.Send(query, CancellationToken.None); - + Result> response = await this.Mediator.Send(query, CancellationToken.None); + if (response.IsFailed) + { + // TODO: Handle error properly, e.g., show a message to the user + } List resultList = new(); - foreach (MerchantModel merchantModel in response) + foreach (MerchantModel merchantModel in response.Data) { resultList.Add(new SelectListItem { diff --git a/EstateManagementUI/Pages/Merchant/MerchantDetails/Merchant.cs b/EstateManagementUI/Pages/Merchant/MerchantDetails/Merchant.cs index f3b3d880..00423343 100644 --- a/EstateManagementUI/Pages/Merchant/MerchantDetails/Merchant.cs +++ b/EstateManagementUI/Pages/Merchant/MerchantDetails/Merchant.cs @@ -80,15 +80,15 @@ protected async Task LoadMerchant(CancellationToken cancellationToken) { Queries.GetMerchantQuery query = new(this.AccessToken, this.EstateId, this.MerchantId); Result result = await this.Mediator.Send(query, cancellationToken); - //if (result.IsFailed) - //{ - // // handle this - //} - + if (result.IsFailed) + { + // handle this + } + // We need to now get all the contracts here to populate the names on the Merchant Model Queries.GetContractsQuery contractsQuery = new Queries.GetContractsQuery(this.AccessToken, this.EstateId); - var contractsResult = await this.Mediator.Send(contractsQuery, cancellationToken); - if (result.IsFailed) { + Result> contractsResult = await this.Mediator.Send(contractsQuery, cancellationToken); + if (contractsResult.IsFailed) { // TODO: Handle this } @@ -128,7 +128,7 @@ protected async Task LoadMerchant(CancellationToken cancellationToken) { this.Contracts = new List(); foreach (MerchantContractModel merchantContractModel in result.Data.Contracts) { - ContractModel contract = contractsResult.SingleOrDefault(c => c.ContractId == merchantContractModel.ContractId); + ContractModel contract = contractsResult.Data.SingleOrDefault(c => c.ContractId == merchantContractModel.ContractId); this.Contracts.Add(new MerchantContractModel { ContractId = merchantContractModel.ContractId, IsDeleted = merchantContractModel.IsDeleted, diff --git a/EstateManagementUI/Pages/Merchant/MerchantsList/MerchantsList.cshtml.cs b/EstateManagementUI/Pages/Merchant/MerchantsList/MerchantsList.cshtml.cs index 7d72d7cf..6b0df5b7 100644 --- a/EstateManagementUI/Pages/Merchant/MerchantsList/MerchantsList.cshtml.cs +++ b/EstateManagementUI/Pages/Merchant/MerchantsList/MerchantsList.cshtml.cs @@ -14,6 +14,7 @@ using EstateManagementUI.Pages.Shared.Components; using Microsoft.AspNetCore.Mvc; using Shared.Logger; +using SimpleResults; namespace EstateManagementUI.Pages.Merchant.MerchantsList { @@ -54,10 +55,13 @@ private async Task GetMerchants() Queries.GetMerchantsQuery query = new Queries.GetMerchantsQuery(AccessToken, EstateId); - List response = await Mediator.Send(query, CancellationToken.None); - + Result> response = await Mediator.Send(query, CancellationToken.None); + if (response.IsFailed) + { + // TODO: Handle error properly, e.g., show a message to the user + } List resultList = new(); - foreach (MerchantModel merchantModel in response) { + foreach (MerchantModel merchantModel in response.Data) { resultList.Add(new ViewModels.Merchant { Id = merchantModel.MerchantId, Name = merchantModel.MerchantName,