Adding tests for users and roles

This commit is contained in:
2025-03-17 23:34:52 +01:00
parent e7b3acb91e
commit db37ebbdce
7 changed files with 501 additions and 24 deletions

View File

@@ -14,6 +14,7 @@ public interface IUserService
Task<User?> GetUserByUsernameAndPassword(string email, string password);
Task<bool> CheckIfEmailIsValid(string email, string? guid = "");
Task<User?> CreateUserAsync(CreateUserRequestData data, Role role);
Task<bool?> DeleteUserAsync(User user);
}
public class UserService : BaseService, IUserService
@@ -117,6 +118,23 @@ public class UserService : BaseService, IUserService
return user;
}
public async Task<bool?> DeleteUserAsync(User user)
{
bool? deleted = false;
using (var transaction = _sqlServerContext.Database.BeginTransactionAsync())
{
user.IsDeleted = true;
user.DeletionTime = DateTime.UtcNow;
_sqlServerContext.Update(user);
await _sqlServerContext.SaveChangesAsync();
await (await transaction).CommitAsync();
deleted = true;
}
return deleted;
}
}