Media object
The media object component can be used to build hierarchical style lists such as blog comments or tweets. In the following example application, we'll use it to return a search result view when the user searches for employees. Our model will have a 'ReportsTo'
field indicating which employee other employees report to; the media object component would be ideal to indicate this visually.
The method located in SearchController
that searches for the employees and returns the results to the view is as follows:
public IActionResult SearchEmployees(string query) { ViewBag.SearchQuery = query; var employees = GetEmployees(); if (!string.IsNullOrEmpty(query)) { var results = employees.Where(p => p.Name.Contains(query)); return View(results); } return View(employees); }
The preceding code will retrieve a list of employees using the GetEmployees
method and, if the query parameter is not empty, return employees matching...