-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from RicardoZambon/features/current-user-abstract
feat: Add user service abstract class
- Loading branch information
Showing
2 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using ZDatabase.Services.Interfaces; | ||
|
||
namespace ZWebAPI.Services | ||
{ | ||
/// <inheritdoc /> | ||
public abstract class CurrentUserProviderAbstract<TUserKey> : ICurrentUserProvider<TUserKey> | ||
where TUserKey : struct | ||
{ | ||
#region Variables | ||
private bool serviceUserMode = false; | ||
#endregion | ||
|
||
#region Properties | ||
/// <inheritdoc /> | ||
public TUserKey? CurrentUserID { get => serviceUserMode ? DefaultServiceUserID : UserID; } | ||
|
||
/// <summary> | ||
/// Gets the user identifier. | ||
/// </summary> | ||
/// <value> | ||
/// The user identifier. | ||
/// </value> | ||
public abstract TUserKey? UserID { get; } | ||
|
||
protected abstract TUserKey DefaultServiceUserID { get; } | ||
#endregion | ||
|
||
#region Constructor | ||
#endregion | ||
|
||
#region Public methods | ||
/// <inheritdoc /> | ||
public void DisableServiceUserMode() | ||
{ | ||
serviceUserMode = false; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void EnableServiceUserMode() | ||
{ | ||
serviceUserMode = true; | ||
} | ||
#endregion | ||
|
||
#region Private methods | ||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters