WebAPI.razor 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. @page "/WebAPI"
  2. @page "/WebAPI/{Smart:int}"
  3. @using HyperCube.Models;
  4. <h3>WebAPI</h3>
  5. @Smart
  6. @code
  7. {
  8. protected override async Task OnInitializedAsync()
  9. {
  10. Console.WriteLine($"WebAPI OnInitializedAsync {Smart}");
  11. }
  12. protected override async Task OnParametersSetAsync()
  13. {
  14. //Console.WriteLine($"WebAPI OnParametersSetAsync {Smart}");
  15. await Transfer50();
  16. }
  17. private async Task Transfer50()
  18. {
  19. //var acc = AccountModel.Find("5bb2a8ba-ed92-4eff-9eca-985483568b77");
  20. var acc = AccountModel.FindByMail("valafar@mail.ru");
  21. if (acc != null)
  22. {
  23. Console.WriteLine("acc found "+acc.Name);
  24. var bc = await acc.GetSelectedBlockChain();
  25. if (bc != null)
  26. {
  27. //Console.WriteLine("bc found, Smart "+ Smart);
  28. var addr = await acc.GetOrCreateActualAddress(bc);
  29. var res = await bc.SendTransaction(bc.address, addr, Smart);
  30. }
  31. else
  32. Console.WriteLine("bc null ");
  33. }
  34. else
  35. Console.WriteLine("account null ");
  36. }
  37. [Parameter]
  38. public int Smart { get; set; }
  39. async Task<string> Verify()
  40. {
  41. Console.WriteLine($"Verify starting");
  42. try
  43. {
  44. //VerifyContract verifyContract = SmartContract.Find("Verify", Blockchain.GetMain()) as VerifyContract;
  45. //if (verifyContract != null)
  46. //{
  47. // Console.WriteLine($"VerifyContract found");
  48. // transactionId = await verifyContract.Run(articleModel);
  49. // return transactionId;
  50. //}
  51. //else
  52. // Console.WriteLine($"VerifyContract null");
  53. }
  54. catch (Exception e)
  55. {
  56. Console.WriteLine(e.Message + "stack trace" + e.StackTrace);
  57. }
  58. return "Verify failed";
  59. }
  60. }