35 lines
782 B
C#
35 lines
782 B
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using PetWash.Api.Data;
|
|
|
|
namespace PetWash.Api.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
public class PackagesController : ControllerBase
|
|
{
|
|
private readonly PetWashDbContext _context;
|
|
|
|
public PackagesController(PetWashDbContext context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
[HttpGet]
|
|
public async Task<IActionResult> GetPackages()
|
|
{
|
|
var packages = await _context.Packages.ToListAsync();
|
|
return Ok(packages);
|
|
}
|
|
|
|
[HttpGet("{id}")]
|
|
public async Task<IActionResult> GetPackage(int id)
|
|
{
|
|
var package = await _context.Packages.FindAsync(id);
|
|
if (package == null)
|
|
return NotFound();
|
|
|
|
return Ok(package);
|
|
}
|
|
}
|