QlbrcContext.cs 958 B

12345678910111213141516171819202122232425262728293031
  1. using System.Security.Principal;
  2. using Quadarax.Foundation.Core.Data.Interface.Domain;
  3. namespace Quadarax.Application.QLiberace.Common.Domain
  4. {
  5. public class QlbrcContext : IContext
  6. {
  7. public IPrincipal CurrentUser { get; }
  8. public string? TenantCode { get; }
  9. public long? TenantId { get; }
  10. public QlbrcContext(IPrincipal? currentUser, string? tenantCode, long? tenantId)
  11. {
  12. if (currentUser == null)
  13. {
  14. var genericIdentity = new GenericIdentity("genericIdentity");
  15. currentUser = new GenericPrincipal(genericIdentity, Array.Empty<string>());
  16. }
  17. CurrentUser = currentUser;
  18. TenantCode = tenantCode;
  19. TenantId = tenantId;
  20. }
  21. public TContext GetContext<TContext>() where TContext : IContext
  22. {
  23. return (TContext)(IContext)this;
  24. }
  25. }
  26. }