LMS.service/LMS.DAO/RoleDAO/RoleBasicDao.cs
2024-10-13 17:04:47 +08:00

29 lines
848 B
C#

using LMS.Repository.Models.DB;
using Microsoft.AspNetCore.Identity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LMS.DAO.RoleDAO
{
public class RoleBasicDao(ApplicationDbContext context, RoleManager<Role> roleManager)
{
private readonly ApplicationDbContext _context = context;
private readonly RoleManager<Role> _roleManager = roleManager;
/// <summary>
/// 检查角色是不是存在
/// </summary>
/// <param name="roleName"></param>
/// <returns></returns>
public async Task<bool> CheckRoleExistById(long? roleId)
{
if (roleId == null)
return false;
return await _roleManager.FindByIdAsync(roleId.ToString()) != null;
}
}
}