Switch to SmartRes Result/Error, upgrade to .NET 10

Migrate codebase to use SmartRes Result<T, Error> (and Unit) across services and interfaces, replacing previous Result usage and updating many method signatures and implementations. Add ResultExtensions to convert SmartRes results to ASP.NET ActionResult and refactor AuthController to use functional Bind/Tap chains for registration/login flows. Upgrade projects to .NET 10 and bump related NuGet packages; add libs/SmartRes.dll and project references. Simplify DbContext registration to use Npgsql only with retry policies and enable detailed logging. Update Swagger/launch settings and other minor fixes (AutoMapper registration change, whitespace/exception handling, and removal of the Govor.ConsoleClient files).
This commit is contained in:
Artemy
2026-07-25 20:20:45 +07:00
parent 6d1c53beeb
commit 3c785d5c89
65 changed files with 376 additions and 838 deletions
+6 -5
View File
@@ -2,6 +2,7 @@
using Govor.Domain.Common;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using SmartRes;
namespace Govor.Application.Profiles;
@@ -16,7 +17,7 @@ public class ProfileService : IProfileService
_logger = logger;
}
public async Task<Result<UserProfile>> GetUserProfileAsync(Guid userId)
public async Task<Result<UserProfile, Error>> GetUserProfileAsync(Guid userId)
{
_logger.LogInformation("Getting user {UserId} profile", userId);
@@ -34,13 +35,13 @@ public class ProfileService : IProfileService
if (profile is null)
{
return Result<UserProfile>.Failure(CreateNotFoundError(userId));
return Result.Failure<UserProfile>(CreateNotFoundError(userId));
}
return profile;
}
public async Task<Result> SetDescription(string description, Guid userId)
public async Task<Result<Unit, Error>> SetDescription(string description, Guid userId)
{
_logger.LogInformation("Updating description for user {UserId}", userId);
@@ -56,7 +57,7 @@ public class ProfileService : IProfileService
return Result.Success();
}
public async Task<Result> SetNewIcon(Guid userId, Guid iconId)
public async Task<Result<Unit, Error>> SetNewIcon(Guid userId, Guid iconId)
{
_logger.LogInformation("Updating icon for user {UserId}", userId);
@@ -74,5 +75,5 @@ public class ProfileService : IProfileService
}
private static Error CreateNotFoundError(Guid userId) =>
new("Profile.UserNotFound", $"User with ID {userId} was not found.");
Error.NotFound("Profile.UserNotFound", $"User with ID {userId} was not found.");
}