26 lines
856 B
C#
26 lines
856 B
C#
using Marco.Pms.DataAccess.Data;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Marco.Pms.Services.Service
|
|
{
|
|
public class PermissionServices
|
|
{
|
|
private readonly ApplicationDbContext _context;
|
|
public PermissionServices(ApplicationDbContext context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
public async Task<bool> HasPermission(Guid featurePermissionId, Guid employeeId)
|
|
{
|
|
var hasPermission = await _context.EmployeeRoleMappings
|
|
.Where(er => er.EmployeeId == employeeId)
|
|
.Select(er => er.RoleId)
|
|
.Distinct()
|
|
.AnyAsync(roleId => _context.RolePermissionMappings
|
|
.Any(rp => rp.FeaturePermissionId == featurePermissionId && rp.ApplicationRoleId == roleId));
|
|
return hasPermission;
|
|
}
|
|
}
|
|
}
|