Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions FileProcessor.BusinessLogic/FileProcessor.BusinessLogic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EstateManagement.Database" Version="2024.8.2-build128" />
<PackageReference Include="EstateManagement.Database" Version="2025.1.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.3" />
<PackageReference Include="EstateManagement.Client" Version="2024.8.2-build128" />
<PackageReference Include="SecurityService.Client" Version="2024.88.2-build73" />
<PackageReference Include="Shared" Version="2024.11.4" />
<PackageReference Include="Shared.DomainDrivenDesign" Version="2024.11.4" />
<PackageReference Include="EstateManagement.Client" Version="2025.1.5" />
<PackageReference Include="SecurityService.Client" Version="2025.1.1" />
<PackageReference Include="Shared" Version="2025.1.2" />
<PackageReference Include="Shared.DomainDrivenDesign" Version="2025.1.2" />
<PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="Shared.EventStore" Version="2024.11.4" />
<PackageReference Include="Shared.EventStore" Version="2025.1.2" />
<PackageReference Include="System.IO.Abstractions" Version="21.0.2" />
<PackageReference Include="TransactionProcessor.Client" Version="2024.8.2-build119" />
<PackageReference Include="TransactionProcessor.Client" Version="2025.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" />
</ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion FileProcessor.Client/FileProcessor.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ClientProxyBase" Version="2024.11.4" />
<PackageReference Include="ClientProxyBase" Version="2025.1.2" />
<PackageReference Include="Shared.Results" Version="2025.1.2" />
</ItemGroup>

<ItemGroup>
Expand Down
99 changes: 8 additions & 91 deletions FileProcessor.Client/FileProcessorClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace FileProcessor.Client {
using Shared.Results;

namespace FileProcessor.Client {
using System;
using System.Collections.Generic;
using System.Net.Http;
Expand All @@ -14,7 +16,7 @@
/// <summary>
///
/// </summary>
/// <seealso cref="ClientProxyBase.ClientProxyBase" />
/// <seealso cref="ClientProxyBase" />
/// <seealso cref="FileProcessor.Client.IFileProcessorClient" />
public class FileProcessorClient : ClientProxyBase, IFileProcessorClient {
#region Fields
Expand Down Expand Up @@ -76,7 +78,7 @@ public async Task<Result<FileDetails>> GetFile(String accessToken,
return ResultHelpers.CreateFailure(result);

ResponseData<FileDetails> responseData =
JsonConvert.DeserializeObject<ResponseData<FileDetails>>(result.Data);
HandleResponseContent<FileDetails>(result.Data);

// call was successful so now deserialise the body to the response object
response = responseData.Data;
Expand Down Expand Up @@ -128,7 +130,7 @@ public async Task<Result<FileImportLog>> GetFileImportLog(String accessToken,
return ResultHelpers.CreateFailure(result);

ResponseData<FileImportLog> responseData =
JsonConvert.DeserializeObject<ResponseData<FileImportLog>>(result.Data);
HandleResponseContent<FileImportLog>(result.Data);

// call was successful so now deserialise the body to the response object
response = responseData.Data;
Expand Down Expand Up @@ -183,7 +185,7 @@ public async Task<Result<FileImportLogList>> GetFileImportLogs(String accessToke
return ResultHelpers.CreateFailure(result);

ResponseData<FileImportLogList> responseData =
JsonConvert.DeserializeObject<ResponseData<FileImportLogList>>(result.Data);
HandleResponseContent<FileImportLogList>(result.Data);

// call was successful so now deserialise the body to the response object
response = responseData.Data;
Expand Down Expand Up @@ -241,7 +243,7 @@ public async Task<Result<Guid>> UploadFile(String accessToken,
return ResultHelpers.CreateFailure(result);

ResponseData<Guid> responseData =
JsonConvert.DeserializeObject<ResponseData<Guid>>(result.Data);
HandleResponseContent<Guid>(result.Data);

// call was successful so now deserialise the body to the response object
response = responseData.Data;
Expand Down Expand Up @@ -271,89 +273,4 @@ private String BuildRequestUrl(String route) {

#endregion
}

internal class ResponseData<T> {
public T Data { get; set; }
}

public static class ResultHelpers {
public static Result CreateFailure(Result result) {
if (result.IsFailed) {
return BuildResult(result.Status, result.Message, result.Errors);
}

return Result.Failure("Unknown Failure");
}

public static Result CreateFailure<T>(Result<T> result) {
if (result.IsFailed) {
return BuildResult(result.Status, result.Message, result.Errors);
}

return Result.Failure("Unknown Failure");
}

private static Result BuildResult(ResultStatus status,
String messageValue,
IEnumerable<String> errorList) {
return (status, messageValue, errorList) switch {
// If the status is NotFound and there are errors, return the errors
(ResultStatus.NotFound, _, List<string> errors) when errors is { Count: > 0 } =>
Result.NotFound(errors),

// If the status is NotFound and the message is not null or empty, return the message
(ResultStatus.NotFound, string message, _) when !string.IsNullOrEmpty(message) => Result.NotFound(
message),

// If the status is Failure and there are errors, return the errors
(ResultStatus.Failure, _, List<string> errors) when errors is { Count: > 0 } => Result.Failure(errors),

// If the status is Failure and the message is not null or empty, return the message
(ResultStatus.Failure, string message, _) when !string.IsNullOrEmpty(message) =>
Result.Failure(message),

// If the status is Forbidden and there are errors, return the errors
(ResultStatus.Forbidden, _, List<string> errors) when errors is { Count: > 0 } => Result.Forbidden(
errors),

// If the status is Forbidden and the message is not null or empty, return the message
(ResultStatus.Forbidden, string message, _) when !string.IsNullOrEmpty(message) => Result.NotFound(
message),
//###
// If the status is Invalid and there are errors, return the errors
(ResultStatus.Invalid, _, List<string> errors) when errors is { Count: > 0 } => Result.Invalid(errors),

// If the status is Invalid and the message is not null or empty, return the message
(ResultStatus.Invalid, string message, _) when !string.IsNullOrEmpty(message) =>
Result.Invalid(message),

// If the status is Unauthorized and there are errors, return the errors
(ResultStatus.Unauthorized, _, List<string> errors) when errors is { Count: > 0 } =>
Result.Unauthorized(errors),

// If the status is Unauthorized and the message is not null or empty, return the message
(ResultStatus.Unauthorized, string message, _) when !string.IsNullOrEmpty(message) => Result
.Unauthorized(message),

// If the status is Conflict and there are errors, return the errors
(ResultStatus.Conflict, _, List<string> errors) when errors is { Count: > 0 } =>
Result.Conflict(errors),

// If the status is Conflict and the message is not null or empty, return the message
(ResultStatus.Conflict, string message, _) when !string.IsNullOrEmpty(message) => Result.Conflict(
message),

// If the status is CriticalError and there are errors, return the errors
(ResultStatus.CriticalError, _, List<string> errors) when errors is { Count: > 0 } => Result
.CriticalError(errors),

// If the status is CriticalError and the message is not null or empty, return the message
(ResultStatus.CriticalError, string message, _) when !string.IsNullOrEmpty(message) => Result
.CriticalError(message),

// Default case, return a generic failure message
_ => Result.Failure("An unexpected error occurred.")
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Shared.DomainDrivenDesign" Version="2024.11.4" />
<PackageReference Include="Shared.DomainDrivenDesign" Version="2025.1.2" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

<ItemGroup>
<PackageReference Include="Grpc.Net.Client" Version="2.61.0" />
<PackageReference Include="Shared.DomainDrivenDesign" Version="2024.11.4" />
<PackageReference Include="Shared.EventStore" Version="2024.11.4" />
<PackageReference Include="Shared.DomainDrivenDesign" Version="2025.1.2" />
<PackageReference Include="Shared.EventStore" Version="2025.1.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Shared.DomainDrivenDesign" Version="2024.11.4" />
<PackageReference Include="Shared.DomainDrivenDesign" Version="2025.1.2" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<ItemGroup>
<PackageReference Include="Grpc.Net.Client" Version="2.61.0" />
<PackageReference Include="Shared.EventStore" Version="2024.11.4" />
<PackageReference Include="Shared.EventStore" Version="2025.1.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EstateManagement.IntegrationTesting.Helpers" Version="2024.8.2-build128" />
<PackageReference Include="Shared.IntegrationTesting" Version="2024.11.4" />
<PackageReference Include="EstateManagement.IntegrationTesting.Helpers" Version="2025.1.5" />
<PackageReference Include="Shared.IntegrationTesting" Version="2025.1.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="EstateManagement.IntegrationTesting.Helpers" Version="2024.8.2-build128" />
<PackageReference Include="EstateManagement.IntegrationTesting.Helpers" Version="2025.1.5" />
<PackageReference Include="EventStoreProjections" Version="2023.12.3" />
<PackageReference Include="MessagingService.IntegrationTesting.Helpers" Version="2024.8.2-build65" />
<PackageReference Include="MessagingService.IntegrationTesting.Helpers" Version="2025.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.3" />
<PackageReference Include="Ductus.FluentDocker" Version="2.10.59" />
<PackageReference Include="EstateManagement.Client" Version="2024.8.2-build128" />
<PackageReference Include="EstateManagement.Client" Version="2025.1.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Reqnroll.Tools.MsBuild.Generation" Version="1.0.1" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Reqnroll" Version="1.0.1" />
<PackageReference Include="Reqnroll.NUnit" Version="1.0.1" />
<PackageReference Include="SecurityService.Client" Version="2024.88.2-build73" />
<PackageReference Include="SecurityService.IntegrationTesting.Helpers" Version="2024.88.2-build73" />
<PackageReference Include="Shared" Version="2024.11.4" />
<PackageReference Include="Shared.IntegrationTesting" Version="2024.11.4" />
<PackageReference Include="SecurityService.Client" Version="2025.1.1" />
<PackageReference Include="SecurityService.IntegrationTesting.Helpers" Version="2025.1.1" />
<PackageReference Include="Shared" Version="2025.1.2" />
<PackageReference Include="Shared.IntegrationTesting" Version="2025.1.2" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="TransactionProcessor.Client" Version="2024.8.2-build119" />
<PackageReference Include="TransactionProcessor.IntegrationTesting.Helpers" Version="2024.8.2-build119" />
<PackageReference Include="TransactionProcessor.Client" Version="2025.1.4" />
<PackageReference Include="TransactionProcessor.IntegrationTesting.Helpers" Version="2025.1.4" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
2 changes: 1 addition & 1 deletion FileProcessor/FileProcessor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Shared" Version="2024.11.4" />
<PackageReference Include="Shared" Version="2025.1.2" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
Expand Down
Loading