Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form asp-action="SearchByText" asp-route-topicId="@Model.Id">
- <div asp-validation-summary="ModelOnly" class="text-danger"></div>
- <div class="form-group">
- <label name="query" class="col-md-2 control-label"></label>
- <div class="col-md-10">
- <input name="query" class="form-control" />
- </div>
- </div>
- <div class="form-group">
- <input type="submit" value="Search" class="btn btn-default" />
- </div>
- </form>
- [AllowAnonymous]
- public async Task<IActionResult> SearchByText(Guid? topicId, String query)
- {
- if (topicId == null)
- {
- return NotFound();
- }
- var forumTopic = await context.ForumTopics
- .Include(f => f.Creator)
- .Include(f => f.Forum)
- .Include(f => f.Messages)
- .ThenInclude(f => f.Creator)
- .Include(f => f.Messages)
- .ThenInclude(f => f.Attachments)
- .SingleOrDefaultAsync(m => m.Id == topicId);
- forumTopic.Messages = forumTopic.Messages.Where(p => p.Creator.Email.Equals(query)).ToList();
- if (forumTopic == null)
- {
- return NotFound();
- }
- this.ViewBag.Query = query;
- return View(forumTopic);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement