AccountModel.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using System.Numerics;
  3. using System.Threading.Tasks;
  4. using System.Collections.Generic;
  5. namespace HyperCube.Models
  6. {
  7. public enum Role { Admin = 0, Verifier, User }
  8. public class AccountModel
  9. {
  10. public static Dictionary<string, AccountModel> Loaded = new();
  11. public static AccountModel Current;
  12. public string eth_address { get; set; }
  13. /// <summary>
  14. /// Internal ID
  15. /// </summary>
  16. public uint ID { get; set; }
  17. /// <summary>
  18. /// ASP Identity ID
  19. /// </summary>
  20. public string UUID { get; set; }
  21. public string Name { get; set; }
  22. public string Email { get; set; }
  23. public Role AccRole { get; set; }
  24. public AccountModel()
  25. {
  26. }
  27. public static AccountModel GetCurrent()
  28. {
  29. return Current;
  30. }
  31. public static AccountModel Find(string email)
  32. {
  33. if (email == null)
  34. return null;
  35. if (Loaded.ContainsKey(email))
  36. return Loaded[email];
  37. else
  38. return null;
  39. }
  40. public static BigInteger ConvertBalance(string hex)
  41. {
  42. string newHex = hex.Remove(0, 2);
  43. var balance = System.Numerics.BigInteger.Parse("0"+ newHex, System.Globalization.NumberStyles.HexNumber );
  44. Console.WriteLine($"ConvertBalance {hex} {balance}");
  45. return balance;
  46. }
  47. public static async void InitializeAccounts()
  48. {
  49. Loaded = await MySQLConnector.Instance().SQLSelectASPUsers();
  50. Console.WriteLine("InitializeAccounts");
  51. }
  52. public async Task GetEthAddress()
  53. {
  54. var addr = await Blockchain.GetMain().CreateBlockchainAccount(this);
  55. }
  56. }
  57. }