You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LuBusinessExtensions.cs 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Luticate2.Auth.Dbo.Tokens;
  5. using Luticate2.Auth.Dbo.Users;
  6. using Luticate2.Utils.Dbo.Basic;
  7. using Luticate2.Utils.Dbo.Result;
  8. using Luticate2.Utils.Utils;
  9. namespace Luticate2.Auth.Business
  10. {
  11. public static class LuBusinessExtensions
  12. {
  13. public static IEnumerable<LuUsersDbo> ToLite(this IEnumerable<LuUsersFullDbo> userRes)
  14. {
  15. return userRes.Select(fullDbo => fullDbo.ToLite());
  16. }
  17. public static LuResult<LuUsersDbo> ToLite(this LuResult<LuUsersFullDbo> userRes)
  18. {
  19. return userRes.To(dbo => dbo.ToLite());
  20. }
  21. public static LuResult<LuPaginatedDbo<LuUsersDbo>> ToLite(this LuResult<LuPaginatedDbo<LuUsersFullDbo>> userRes)
  22. {
  23. return userRes.To(dbo => dbo.To(dbos => dbos.ToLite().ToList()));
  24. }
  25. public static LuUsersDbo ToLite(this LuUsersFullDbo dbo)
  26. {
  27. if (dbo == null)
  28. {
  29. return null;
  30. }
  31. return new LuUsersDbo
  32. {
  33. Id = dbo.Id,
  34. Username = dbo.Username
  35. };//TODO
  36. }
  37. public static LuUsersToken ToUserToken(this LuTokensDbo dbo)
  38. {
  39. if (dbo == null)
  40. {
  41. return null;
  42. }
  43. return new LuUsersToken
  44. {
  45. Data = dbo.Data,
  46. NotAfter = dbo.NotAfter,
  47. NotBefore = dbo.NotBefore,
  48. UserId = dbo.UserId
  49. };
  50. }
  51. }
  52. }