mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
31 lines
727 B
C#
31 lines
727 B
C#
using System;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using MusicStore.Models;
|
|
|
|
namespace MusicStore.Apis
|
|
{
|
|
[Route("api/artists")]
|
|
public class ArtistsApiController : Controller
|
|
{
|
|
private readonly MusicStoreContext _storeContext;
|
|
|
|
public ArtistsApiController(MusicStoreContext storeContext)
|
|
{
|
|
_storeContext = storeContext;
|
|
}
|
|
|
|
[HttpGet("lookup")]
|
|
public async Task<ActionResult> Lookup()
|
|
{
|
|
var artists = await _storeContext.Artists
|
|
.OrderBy(a => a.Name)
|
|
.ToListAsync();
|
|
|
|
return Json(artists);
|
|
}
|
|
}
|
|
}
|