user service with editing, removing and reading accounts methods, controller actions for this service

This commit is contained in:
2024-08-22 00:23:02 +03:00
parent d1d3a1ab73
commit 85bac2b0a4
8 changed files with 140 additions and 9 deletions

View File

@@ -0,0 +1,34 @@
using ApplicationLayer.InfrastructureServicesInterfaces;
using ApplicationLayer.Services.AuthServices.NeededServices;
using ApplicationLayer.Services.AuthServices.Requests;
using Domains.Users;
namespace ApplicationLayer.Services.ApprovingAuthorities
{
public class UsersService(IUsersRepository users, IUnitOfWork unitOfWork) : IUsersService
{
async Task<List<User>> IUsersService.GetAuthoritiesAccountsAsync(CancellationToken cancellationToken)
{
return await users.GetAllOfRoleAsync(Role.ApprovingAuthority, cancellationToken);
}
async Task IUsersService.ChangeAccountAuthDataAsync(Guid userId, RegisterRequest data, CancellationToken cancellationToken)
{
var user = await users.GetByIdAsync(userId, cancellationToken);
user.Email = data.Email;
user.Password = data.Password;
await users.UpdateAsync(user, cancellationToken);
await unitOfWork.SaveAsync(cancellationToken);
}
async Task IUsersService.RemoveUserAccount(Guid userId, CancellationToken cancellationToken)
{
var user = await users.GetByIdAsync(userId, cancellationToken);
users.Remove(user);
await unitOfWork.SaveAsync(cancellationToken);
}
}
}