Verifying.razor 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. @page "/verifying"
  2. @using System.ComponentModel.DataAnnotations;
  3. @using System.Linq;
  4. @using System.Reflection;
  5. @attribute [Authorize]
  6. <h1>Верификация</h1>
  7. <table class="table">
  8. <thead>
  9. <tr>
  10. <th>№</th>
  11. @*<th>Файл</th>*@
  12. <th>Название</th>
  13. <th>Дата издания</th>
  14. @*<th>Авторы</th>*@
  15. <th>Инициатор</th>
  16. <th>Верификатор</th>
  17. <th>Статус</th>
  18. </tr>
  19. </thead>
  20. <tbody>
  21. @foreach (var articleModel in articleModels)
  22. {
  23. <tr>
  24. <td>@(counter++)</td>
  25. @*<td>@articleModel.Value.Filename</td>*@
  26. <td><a href="@($"/docedit/{articleModel.Key}")">@articleModel.Value.Name</a></td>
  27. <td>@articleModel.Value.PublishDate.ToString("d")</td>
  28. @*<td>@articleModel.Value.Authors</td>*@
  29. <td><center> - </center></td>
  30. <td><center> - </center></td>
  31. <td>@GetDisplayName(articleModel.Value.Status)</td>
  32. </tr>
  33. }
  34. </tbody>
  35. </table>
  36. @code {
  37. private Dictionary<int, Models.ArticleModel> articleModels;
  38. private int counter = 1;
  39. protected override async Task OnInitializedAsync()
  40. {
  41. MySQLConnector dbCon = MySQLConnector.Instance();
  42. string stringSQL = $"SELECT a.id, filename, article_name, date_publish, authors, ah.action_type " +
  43. $"FROM articles a " +
  44. $"LEFT JOIN actions_history ah ON a.id = ah.article_id " +
  45. $"AND EXISTS (SELECT 1 FROM actions_history ah1 WHERE ah.article_id = ah1.article_id HAVING MAX(ah1.date_add) = ah.date_add) " +
  46. $"ORDER BY a.id";
  47. articleModels = await dbCon.SQLSelectArticles(stringSQL);
  48. dbCon.Close();
  49. //status = results;
  50. }
  51. private static string GetDisplayName(Enum enumValue)
  52. {
  53. return enumValue.GetType()
  54. .GetMember(enumValue.ToString())
  55. .First()
  56. .GetCustomAttribute<DisplayAttribute>()
  57. .GetName();
  58. }
  59. }