public static string ToAdminHtml(this ContestListModel model) { return($@" <tr> <td>{model.Name}</td> <td>{model.Submissions}</td> <td> <a href=""/contests/edit?id={model.Id}"" class=""btn btn-sm btn-warning"">Edit</a> <a href=""/contests/delete?id={model.Id}"" class=""btn btn-sm btn-danger"">Delete</a> </td> </tr>"); }
public async Task<ContestListModel> ContestList([FromBody]ContestListQueryModel model) { var userId = userManager.GetUserId(User); var ret = new ContestListModel(); IQueryable<Contest> contests; try { contests = await (model.GroupId switch { 0 => contestService.QueryContestAsync(userId), _ => contestService.QueryContestAsync(userId, model.GroupId) }); }
//public static string ToHtml(this GameListingHomeModel game, bool isAdmin) // => ""; public static string ToHtml(this ContestListModel model, bool isAdmin, string email) { var result = new StringBuilder(); result.Append($@"<tr> <td scope=""row"">{model.ContestName}</td> <td>{model.Submissions}</td> <td>"); if (isAdmin || model.CreatorEmail == email) { result.Append($@"<a href=""/contests/edit?id={model.Id}"" class=""btn btn-sm btn-warning"" >Edit</a> <a href= ""/contests/delete?id={model.Id}"" class=""btn btn-sm btn-danger"" >Delete</a>"); } result.AppendLine(@"</td></tr>"); return(result.ToString()); }