This commit is contained in:
2025-04-30 09:51:36 +08:00
parent 561881c9aa
commit 09afa239a6
848 changed files with 385870 additions and 205 deletions

View File

@@ -0,0 +1,30 @@
namespace Yes.Application.Admins.Users
{
public record UpdateProfileCommand(
string Email,
string NickName,
string Url
) : IRequest<Unit>;
public class UpdateProfileCommandHandler(BlogDbContext db, IIdentityContext identityContext) : IRequestHandler<UpdateProfileCommand, Unit>
{
private readonly BlogDbContext _db = db;
private readonly IIdentityContext _identityContext = identityContext;
public async Task<Unit> Handle(UpdateProfileCommand request, CancellationToken cancellationToken)
{
var userId = _identityContext.Id;
var user = await _db.Users.FindAsync(userId);
if (user == null)
{
throw new UserNotExistsException();
}
user.UpdateProfile(request.Email, request.NickName, request.Url);
_db.Users.Update(user);
await _db.SaveChangesAsync();
return new Unit();
}
}
}