Session.cs 627 B

1234567891011121314151617181920212223242526
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace WindowsFormsApp4
  7. {
  8. public static class Session
  9. {
  10. public static DatabaseHelper.User CurrentUser { get; set; }
  11. public static bool IsLoggedIn => CurrentUser != null;
  12. public static bool IsAdmin => CurrentUser?.Role == "admin";
  13. public static bool IsManager => CurrentUser?.Role == "manager";
  14. public static bool IsClient => CurrentUser?.Role == "client";
  15. public static void Logout()
  16. {
  17. CurrentUser = null;
  18. }
  19. }
  20. }