using System;
namespace Oqtane.Models
{
///
/// Permission information for anything in Oqtane.
/// Things in Oqtane are identified as Entities, so anything that can be identified can be described here.
///
public class Permission : IAuditable
{
///
/// Internal ID storing this information.
///
public int PermissionId { get; set; }
///
/// Reference to the which contains both the target Entity and permissions.
///
public int SiteId { get; set; }
///
/// Name of the Entity these permissions apply to.
///
public string EntityName { get; set; }
///
/// ID of the Entity these permissions apply to.
///
public int EntityId { get; set; }
///
/// What this permission is called.
/// TODO: todoc - must clarify what exactly this means, I assume any module can give it's own names for Permissions
///
public string PermissionName { get; set; }
///
/// this permission applies to. So if all users in the Role _Customers_ have this permission, then it would reference that Role.
/// If null, then the permission doesn't target a role but probably a (see ).
///
public int? RoleId { get; set; }
///
/// this permission applies to.
/// If null, then the permission doesn't target a User but probably a (see ).
///
public int? UserId { get; set; }
///
/// Determines if Authorization is sufficient to receive this permission.
///
public bool IsAuthorized { get; set; }
#region IAuditable Properties
///
public string CreatedBy { get; set; }
///
public DateTime CreatedOn { get; set; }
///
public string ModifiedBy { get; set; }
///
public DateTime ModifiedOn { get; set; }
#endregion
///
/// Reference to the based on the - can be nullable.
///
///
/// It's not certain if this will always be populated. TODO: todoc/verify
///
public Role Role { get; set; }
public Permission()
{
}
public Permission(string permissionName, string roleName, bool isAuthorized)
{
PermissionName = permissionName;
Role = new Role { Name = roleName };
IsAuthorized = isAuthorized;
}
public Permission(string permissionName, int userId, bool isAuthorized)
{
PermissionName = permissionName;
UserId = userId;
IsAuthorized = isAuthorized;
}
}
}