@page "/surveys" @using HyperCube.Models @attribute [Authorize] <h3>Surveys</h3> <div style="margin:10px"> <a href="surveyeditor">Создать новый опрос</a> </div> <div> <table border="1" width="100%"> <tr> <th>EvenID</th> <th>ID</th> <th>Name</th> <th>Description</th> <th>DateCreated</th> <th>DateUpdated</th> <th>CreatorID</th> </tr> @foreach (var survey in _surveys) { <tr> <td>@survey.Value.EvenID</td> <td>@survey.Value.ID</td> <td><a href="@($"/surveyeditor/{survey.Key}")">@survey.Value.Name</a></td> <td>@survey.Value.Description</td> <td>@survey.Value.DateCreated</td> <td>@survey.Value.DateUpdated</td> <td>@survey.Value.CreatorID</td> </tr> } </table> </div> @code { Dictionary<int, Survey> _surveys = new(); protected override async Task OnInitializedAsync() { Survey survey; var surveys = await MySQLConnector.Instance().SQLSelectComplex($"SELECT * FROM surveys WHERE deleted<>1"); if (surveys.Count > 0) { foreach (var s in surveys) { survey = new() { EvenID = Convert.ToInt32(s["eventid"]), ID = Convert.ToInt32(s["id"]), Name = Convert.ToString(s["name"]), Description = Convert.ToString(s["description"]), DateCreated = Convert.ToDateTime(s["date_created"]), DateUpdated = Convert.ToDateTime(s["date_updated"]), CreatorID = Convert.ToString(s["creatorid"]) }; //Console.WriteLine($"add survey. id: {survey.ID}, name: {survey.Name}"); _surveys.Add(survey.ID, survey); } } } }