27 lines
624 B
C#
27 lines
624 B
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace BlazingPizza.Server
|
|
{
|
|
[Route("toppings")]
|
|
[ApiController]
|
|
public class ToppingsController : Controller
|
|
{
|
|
private readonly PizzaStoreContext _db;
|
|
|
|
public ToppingsController(PizzaStoreContext db)
|
|
{
|
|
_db = db;
|
|
}
|
|
|
|
[HttpGet]
|
|
public async Task<ActionResult<List<Topping>>> GetToppings()
|
|
{
|
|
return await _db.Toppings.OrderBy(t => t.Name).ToListAsync();
|
|
}
|
|
}
|
|
}
|