main
|
Last change
on this file since d89d25b 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
|
| Line | |
|---|
| 1 | using KernelRecordsMVC.Infrastructure.Data;
|
|---|
| 2 | using Microsoft.AspNetCore.Mvc;
|
|---|
| 3 | using Microsoft.EntityFrameworkCore;
|
|---|
| 4 |
|
|---|
| 5 | namespace KernelRecordsMVC.Web.Controllers;
|
|---|
| 6 |
|
|---|
| 7 | public 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.