Add operation executor
This commit is contained in:
@ -7,7 +7,7 @@ namespace Hcs.WebApp.Services
|
||||
private readonly Uri baseUri = new($"{navigationManager.BaseUri}identity/");
|
||||
private readonly HttpClient httpClient = factory.CreateClient("WithIdentity");
|
||||
|
||||
public async Task ChangePassword(string oldPassword, string newPassword)
|
||||
public async Task ChangePasswordAsync(string oldPassword, string newPassword)
|
||||
{
|
||||
var uri = new Uri($"{baseUri}change-password");
|
||||
var content = new FormUrlEncodedContent(new Dictionary<string, string> {
|
||||
|
||||
@ -7,13 +7,13 @@ namespace Hcs.WebApp.Services
|
||||
{
|
||||
private readonly IDbContextFactory<HcsDbContext> factory = factory;
|
||||
|
||||
public async Task<bool> HasActiveOperation(Operation.OperationType type)
|
||||
public async Task<bool> HasActiveOperationAsync(Operation.OperationType type)
|
||||
{
|
||||
using var context = factory.CreateDbContext();
|
||||
return await context.Operations.AnyAsync(x => x.Type == type && !x.EndedAt.HasValue);
|
||||
}
|
||||
|
||||
public async Task<Operation> InitiateOperation(Operation.OperationType type, string initiatorId)
|
||||
public async Task<Operation> InitiateOperationAsync(Operation.OperationType type, string initiatorId)
|
||||
{
|
||||
using var context = factory.CreateDbContext();
|
||||
var operation = new Operation()
|
||||
@ -27,7 +27,7 @@ namespace Hcs.WebApp.Services
|
||||
return operation;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Operation>> GetInitiatedOperations()
|
||||
public async Task<IEnumerable<Operation>> GetInitiatedOperationsAsync()
|
||||
{
|
||||
using var context = factory.CreateDbContext();
|
||||
return await (from operation in context.Operations
|
||||
@ -35,7 +35,7 @@ namespace Hcs.WebApp.Services
|
||||
select operation).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task SetOperationMessageGuid(int operationId, string messageGuid)
|
||||
public async Task SetOperationMessageGuidAsync(int operationId, string messageGuid)
|
||||
{
|
||||
using var context = factory.CreateDbContext();
|
||||
var operation = await context.Operations.FirstOrDefaultAsync(x => x.Id == operationId);
|
||||
|
||||
@ -7,7 +7,7 @@ namespace Hcs.WebApp.Services
|
||||
{
|
||||
private readonly IDbContextFactory<HcsDbContext> factory = factory;
|
||||
|
||||
public async Task<IEnumerable<Registry>> GetAllRegistries(bool isCommon)
|
||||
public async Task<IEnumerable<Registry>> GetAllRegistriesAsync(bool isCommon)
|
||||
{
|
||||
using var context = factory.CreateDbContext();
|
||||
return await (from registry in context.Registries
|
||||
|
||||
@ -13,7 +13,7 @@ namespace Hcs.WebApp.Services
|
||||
private readonly UserManager<AppUser> userManager = userManager;
|
||||
private readonly IPasswordHasher<AppUser> passwordHasher = passwordHasher;
|
||||
|
||||
public async Task<IEnumerable<AppUserWithRole>> GetUsersWithRole()
|
||||
public async Task<IEnumerable<AppUserWithRole>> GetUsersWithRoleAsync()
|
||||
{
|
||||
using var context = factory.CreateDbContext();
|
||||
return await (from user in context.Users
|
||||
@ -26,7 +26,7 @@ namespace Hcs.WebApp.Services
|
||||
}).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IdentityResult> CreateUser(string userName, string roleName, string password)
|
||||
public async Task<IdentityResult> CreateUserAsync(string userName, string roleName, string password)
|
||||
{
|
||||
var user = new AppUser()
|
||||
{
|
||||
@ -41,7 +41,7 @@ namespace Hcs.WebApp.Services
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task UpdateUser(string userId, string roleId, string password)
|
||||
public async Task UpdateUserAsync(string userId, string roleId, string password)
|
||||
{
|
||||
using var context = factory.CreateDbContext();
|
||||
using var transaction = await context.Database.BeginTransactionAsync();
|
||||
@ -89,7 +89,7 @@ namespace Hcs.WebApp.Services
|
||||
await transaction.CommitAsync();
|
||||
}
|
||||
|
||||
public async Task<IdentityResult> DeleteUser(string userId)
|
||||
public async Task<IdentityResult> DeleteUserAsync(string userId)
|
||||
{
|
||||
var user = await userManager.FindByIdAsync(userId);
|
||||
return await userManager.DeleteAsync(user);
|
||||
|
||||
Reference in New Issue
Block a user