July 2019
Intermediate to advanced
416 pages
10h 6m
English
We are going to use the power of dependency injection to pass the Discogs client model that we just wrote in:
public class HomeController : Controller{ private readonly IDiscogsClient _discogsClient; public HomeController(IDiscogsClient discogsClient) { _discogsClient = discogsClient; }}
As you may remember, when we were setting up the navigation, we set asp-action to Index. When we perform a search, our view is going to pass the search string over to Index and call the GetByArtist method. When we get the result of the search back, we set ViewBag.Result with the results list. Finally, we serve up View, which will be the Index page:
public async Task<IActionResult> Index(string searchString){ if (!string.IsNullOrWhiteSpace(searchString)) ...Read now
Unlock full access