This commit is contained in:
SpecialX
2025-07-01 19:05:07 +08:00
parent a21ca80782
commit 017cc2169c
33 changed files with 3778 additions and 109 deletions

View File

@@ -1,10 +1,25 @@
using Entities.Contracts;
using Entities.DTO;
using Microsoft.AspNetCore.Identity;
using SharedDATA.Api;
using TechHelper.Services;
namespace TechHelper.Server.Services
{
public class UserServices : IUserSerivces
{
private readonly IUnitOfWork _unitOfWork;
private readonly IClassService _classService;
private readonly UserManager<User> _userManager;
public UserServices(IUnitOfWork unitOfWork, IClassService classService, UserManager<User> userManager)
{
_unitOfWork = unitOfWork;
_classService = classService;
_userManager = userManager;
}
public Task<ApiResponse> AddAsync(User model)
{
throw new NotImplementedException();
@@ -30,9 +45,33 @@ namespace TechHelper.Server.Services
throw new NotImplementedException();
}
public async Task<ApiResponse> RestoreUserRoleInformation(User user)
{
var result = await _classService.GetUserClassRole(user.Id);
if (result.Status)
{
var classRole = result.Result as UserClassRoleDto;
if (classRole != null)
{
if (!await _userManager.IsInRoleAsync(user, classRole.Role))
{
await _userManager.AddToRoleAsync(user, classRole.Role);
return ApiResponse.Success();
}
}
}
return ApiResponse.Error();
}
public Task<ApiResponse> UpdateAsync(User model)
{
throw new NotImplementedException();
}
public Task<ApiResponse> VerifyUserInformation(Guid userId)
{
throw new NotImplementedException();
}
}
}