source: KernelRecordsMVC.Web/Controllers/ArtistController.cs

main
Last change on this file was d89d25b, checked in by mmilevski <markomilevski3@…>, 4 weeks ago

Added few implementaions, minor UI changes.

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[d89d25b]1using KernelRecordsMVC.Infrastructure.Data;
2using Microsoft.AspNetCore.Mvc;
3using Microsoft.EntityFrameworkCore;
4
5namespace KernelRecordsMVC.Web.Controllers;
6
7public class ArtistController : Controller
8{
9 private readonly KernelRecordsContext _context;
10
11 public ArtistController(KernelRecordsContext context)
12 {
13 _context = context;
14 }
15
16
17 // =========================================================
18 // ARTIST LIST
19 // =========================================================
20
21 [HttpGet]
22 public IActionResult Index()
23 {
24 var artists = _context.Artists
25 .OrderBy(a => a.ArtistName)
26 .ToList();
27
28 return View(artists);
29 }
30
31
32 // =========================================================
33 // ARTIST DETAILS
34 // =========================================================
35
36 [HttpGet]
37 public IActionResult Details(long id)
38 {
39 var artist = _context.Artists
40 .Include(a => a.ReleaseArtists)
41 .ThenInclude(ra => ra.Release)
42 .ThenInclude(r => r.Products)
43 .FirstOrDefault(a =>
44 a.ArtistId == id);
45
46 if (artist == null)
47 return NotFound();
48
49 return View(artist);
50 }
51}
Note: See TracBrowser for help on using the repository browser.