Verifying.razor 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. </tr>
  17. </thead>
  18. <tbody>
  19. @foreach (var articleModel in articleModels)
  20. {
  21. <tr>
  22. <td>@(counter++)</td>
  23. <td>@articleModel.Value.Filename</td>
  24. <td><a href="@($"/docedit/{articleModel.Key}")">@articleModel.Value.Name</a></td>
  25. <td>@articleModel.Value.PublishDate.ToString("d")</td>
  26. <td>@articleModel.Value.Authors</td>
  27. <td>@GetDisplayName(articleModel.Value.Status)</td>
  28. </tr>
  29. }
  30. </tbody>
  31. </table>
  32. @code {
  33. private Dictionary<int, Models.ArticleModel> articleModels;
  34. private int counter = 1;
  35. protected override async Task OnInitializedAsync()
  36. {
  37. MySQLConnector dbCon = MySQLConnector.Instance();
  38. string stringSQL = $"SELECT a.id, filename, article_name, date_publish, authors, ah.action_type " +
  39. $"FROM articles a " +
  40. $"LEFT JOIN actions_history ah ON a.id = ah.article_id " +
  41. $"AND EXISTS (SELECT 1 FROM actions_history ah1 WHERE ah.article_id = ah1.article_id HAVING MAX(ah1.date_add) = ah.date_add) " +
  42. $"ORDER BY a.id";
  43. articleModels = await dbCon.SQLSelectArticles(stringSQL);
  44. dbCon.Close();
  45. //status = results;
  46. }
  47. private static string GetDisplayName(Enum enumValue)
  48. {
  49. return enumValue.GetType()
  50. .GetMember(enumValue.ToString())
  51. .First()
  52. .GetCustomAttribute<DisplayAttribute>()
  53. .GetName();
  54. }
  55. }