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.

ModelsToDbo.cs 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System.Collections.Generic;
  2. using Luticate2.Auth.DataAccess.Models;
  3. using Luticate2.Auth.Dbo.Groups;
  4. using Luticate2.Auth.Dbo.Tokens;
  5. using Luticate2.Auth.Dbo.Users;
  6. using Luticate2.Utils.Utils;
  7. using Newtonsoft.Json;
  8. namespace Luticate2.Auth.DataAccess
  9. {
  10. public static class ModelsToDbo
  11. {
  12. public static LuGroupsDbo ToDbo(this lu_groups model)
  13. {
  14. if (model == null)
  15. {
  16. return null;
  17. }
  18. return new LuGroupsDbo
  19. {
  20. Id = model.id.ToDbo(),
  21. Name = model.name
  22. };
  23. }
  24. public static LuUsersFullDbo ToDbo(this lu_users model)
  25. {
  26. if (model == null)
  27. {
  28. return null;
  29. }
  30. return new LuUsersFullDbo
  31. {
  32. AuthenticationSourceId = model.authentication_source_id.ToDbo(),
  33. Data = JsonConvert.DeserializeObject<IDictionary<string, object>>(model.data),
  34. Id = model.id.ToDbo(),
  35. Password = model.password,
  36. Salt = model.salt,
  37. Username = model.username
  38. };
  39. }
  40. public static LuTokensDbo ToDbo(this lu_tokens model)
  41. {
  42. if (model == null)
  43. {
  44. return null;
  45. }
  46. return new LuTokensDbo
  47. {
  48. Data = JsonConvert.DeserializeObject<IDictionary<string, object>>(model.data),
  49. Id = model.id,
  50. NotAfter = model.notAfter,
  51. NotBefore = model.notBefore,
  52. UserId = model.user_id.ToDbo()
  53. };
  54. }
  55. }
  56. }