sanAntonioSeniorGolf/API/Authentication/ColorAuthentication.cs

45 lines
1.5 KiB
C#
Raw Normal View History

using API.Authentication.GrantNames;
2024-05-20 10:44:18 -05:00
using API.Authentication.Interfaces;
using API.DTO.Base;
using API.Services;
using API.Services.Interfaces;
2024-05-20 10:44:18 -05:00
using DAL.Models;
namespace API.Authentication
{
public class ColorAuthentication : IColorAuthentication
{
private readonly IGrantManager _grantManager;
2024-05-20 10:44:18 -05:00
private readonly ILogger<ColorAuthentication> _logger;
public ColorAuthentication(ILogger<ColorAuthentication> logger, IGrantManager grantManager)
2024-05-20 10:44:18 -05:00
{
_logger = logger;
_grantManager = grantManager;
2024-05-20 10:44:18 -05:00
}
public bool canGetAll(User user)
{
return _grantManager.hasGrant(user.permissionId, ColorGrantNames.CanGetAll);
2024-05-20 10:44:18 -05:00
}
public bool canGet(Color model, User user)
{
return _grantManager.hasGrant(user.permissionId, ColorGrantNames.CanGetAny) ||
_grantManager.getULongValues(user.permissionId, ColorGrantNames.CanGet).Exists(x => x == model.id);
2024-05-20 10:44:18 -05:00
}
public bool canAdd(ColorDTO item, User user)
{
return _grantManager.hasGrant(user.permissionId, ColorGrantNames.CanAdd);
2024-05-20 10:44:18 -05:00
}
public bool canUpdate(Color model, User user)
{
return _grantManager.hasGrant(user.permissionId, ColorGrantNames.CanUpdateAny) ||
_grantManager.getULongValues(user.permissionId, ColorGrantNames.CanUpdate).Exists(x => x == model.id);
2024-05-20 10:44:18 -05:00
}
public bool canDelete(Color model, User user)
{
return _grantManager.hasGrant(user.permissionId, ColorGrantNames.CanDeleteAny) ||
_grantManager.getULongValues(user.permissionId, ColorGrantNames.CanDelete).Exists(x => x == model.id);
2024-05-20 10:44:18 -05:00
}
}
}