temp
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user