using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Snootalogue.Models; using Snootalogue.Data; namespace Snootalogue.Controllers { [Route("/api/[controller]")] [ApiController] public class DocumentController : ControllerBase { private readonly SnootalogueContext _context; public DocumentController(SnootalogueContext context) { _context = context; } [HttpGet] public async Task>> GetDocuments() { return await _context.Document.Take(25).ToListAsync(); } [HttpGet("{id}")] public async Task> GetDocumentById(int id) { var document = await _context.Document.FindAsync(id); if (document == null) { return NotFound(); } return document; } } }