Class BaseEntityWithPermissions
Every entity that requires its own permissions must implement IBaseEntityWithPermissions
You don't have to inherit from this class necessarily, you can implement your own base class
This does contain some static helper functions for working with permissions
Inheritance
Implements
Inherited Members
Namespace: LemonEdge.API.Entities
Assembly: LemonEdge.API.dll
Syntax
[DataContract]
public abstract class BaseEntityWithPermissions : BaseEntity, IBaseEntityWithPermissions, IBaseEntity, IEquatable<IBaseEntity>, INotifyPropertyChanged, INotifyPropertyChanging, ICloneableAsync, ICanTrackProperties
Constructors
BaseEntityWithPermissions()
Declaration
protected BaseEntityWithPermissions()
Methods
CanChangeItemPermissions(object, IEntityRetriever, IReadOnlyCache, Guid)
Returns a task that indicates if the specifed team has permissions to change permissions for the specified item
This works by first checking if the item itself inherits from IBaseEntityWithPermissions. If it does it checks if the item has an individual permission for the team, or the general permissions for the item type as a whole and then ensures they have permissions to change permissions.
If the item does not inherit IBaseEntityWithPermissions then it recursively checks relationships that are marked as inheriting permissions to ensure all those items have the required permissions
Otherwise the item is not permissioned by lemonedge and is just assumed to have full access
Declaration
public static Task<bool> CanChangeItemPermissions(object item, IEntityRetriever con, IReadOnlyCache cache, Guid teamID)
Parameters
Type | Name | Description |
---|---|---|
object | item | The item to check if the team has permissions to change permissions |
IEntityRetriever | con | A context to use to check for permissions if needed |
IReadOnlyCache | cache | The local cache to check cached permissions of if required |
Guid | teamID | The team to check permissions of |
Returns
Type | Description |
---|---|
Task<bool> | A task that indicates if the specifed team has permissions to change permissions for the specified item |
CanDeleteItem(object, IEntityRetriever, IReadOnlyCache, Guid)
Returns a task that indicates if the specifed team has permissions to delete the specified item
This works by first checking if the item itself inherits from IBaseEntityWithPermissions. If it does it checks if the item has an individual permission for the team, or the general permissions for the item type as a whole and then ensures they are delete or greater.
If the item does not inherit IBaseEntityWithPermissions then it recursively checks relationships that are marked as inheriting permissions to ensure all those items have the required permissions
Otherwise the item is not permissioned by lemonedge and is just assumed to have full access
Declaration
public static Task<bool> CanDeleteItem(object item, IEntityRetriever con, IReadOnlyCache cache, Guid teamID)
Parameters
Type | Name | Description |
---|---|---|
object | item | The item to check if the team has permissions to delete |
IEntityRetriever | con | A context to use to check for permissions if needed |
IReadOnlyCache | cache | The local cache to check cached permissions of if required |
Guid | teamID | The team to check permissions of |
Returns
Type | Description |
---|---|
Task<bool> | A task that indicates if the specifed team has permissions to delete the specified item |
CanWriteItem(object, IEntityRetriever, IReadOnlyCache, Guid)
Returns a task that indicates if the specifed team has permissions to edit the specified item
This works by first checking if the item itself inherits from IBaseEntityWithPermissions. If it does it checks if the item has an individual permission for the team, or the general permissions for the item type as a whole and then ensures they are read-write or greater.
If the item does not inherit IBaseEntityWithPermissions then it recursively checks relationships that are marked as inheriting permissions to ensure all those items have the required permissions
Otherwise the item is not permissioned by lemonedge and is just assumed to have full access
Declaration
public static Task<bool> CanWriteItem(object item, IEntityRetriever con, IReadOnlyCache cache, Guid teamID)
Parameters
Type | Name | Description |
---|---|---|
object | item | The item to check if the team has permissions to edit |
IEntityRetriever | con | A context to use to check for permissions if needed |
IReadOnlyCache | cache | The local cache to check cached permissions of if required |
Guid | teamID | The team to check permissions of |
Returns
Type | Description |
---|---|
Task<bool> | A task that indicates if the specifed team has permissions to edit the specified item |
IsLocked(object)
Indicates if this item implements ICanBeLocked and is set to Locked
Declaration
public static bool IsLocked(object item)
Parameters
Type | Name | Description |
---|---|---|
object | item | An item to check to see if it is locked |
Returns
Type | Description |
---|---|
bool | True if this item implements ICanBeLocked and is set to Locked |
PreLoadPermissions<T>(IEnumerable<T>, IEntityRetriever, IReadOnlyCache, Guid)
Declaration
public static Task PreLoadPermissions<T>(IEnumerable<T> items, IEntityRetriever con, IReadOnlyCache cache, Guid teamID) where T : IBaseEntityWithPermissions
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | items | |
IEntityRetriever | con | |
IReadOnlyCache | cache | |
Guid | teamID |
Returns
Type | Description |
---|---|
Task |
Type Parameters
Name | Description |
---|---|
T |