Surveys.razor 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. @page "/surveys"
  2. @using HyperCube.Models
  3. @attribute [Authorize]
  4. <h3>Surveys</h3>
  5. <div style="margin:10px">
  6. <a href="surveyeditor">Создать новый опрос</a>
  7. </div>
  8. <div>
  9. <table border="1" width="100%">
  10. <tr>
  11. <th>EvenID</th>
  12. <th>ID</th>
  13. <th>Name</th>
  14. <th>Description</th>
  15. <th>DateCreated</th>
  16. <th>DateUpdated</th>
  17. <th>CreatorID</th>
  18. </tr>
  19. @foreach (var survey in _surveys)
  20. {
  21. <tr>
  22. <td>@survey.Value.EvenID</td>
  23. <td>@survey.Value.ID</td>
  24. <td><a href="@($"/surveyeditor/{survey.Key}")">@survey.Value.Name</a></td>
  25. <td>@survey.Value.Description</td>
  26. <td>@survey.Value.DateCreated</td>
  27. <td>@survey.Value.DateUpdated</td>
  28. <td>@survey.Value.CreatorID</td>
  29. </tr>
  30. }
  31. </table>
  32. </div>
  33. @code {
  34. Dictionary<int, Survey> _surveys = new();
  35. protected override async Task OnInitializedAsync()
  36. {
  37. Survey survey;
  38. var surveys = await MySQLConnector.Instance().SQLSelectComplex($"SELECT * FROM surveys WHERE deleted<>1");
  39. if (surveys.Count > 0)
  40. {
  41. foreach (var s in surveys)
  42. {
  43. survey = new()
  44. {
  45. EvenID = Convert.ToInt32(s["eventid"]),
  46. ID = Convert.ToInt32(s["id"]),
  47. Name = Convert.ToString(s["name"]),
  48. Description = Convert.ToString(s["description"]),
  49. DateCreated = Convert.ToDateTime(s["date_created"]),
  50. DateUpdated = Convert.ToDateTime(s["date_updated"]),
  51. CreatorID = Convert.ToString(s["creatorid"])
  52. };
  53. //Console.WriteLine($"add survey. id: {survey.ID}, name: {survey.Name}");
  54. _surveys.Add(survey.ID, survey);
  55. }
  56. }
  57. }
  58. }