diff --git a/Controllers/DocumentController.cs b/Controllers/DocumentController.cs new file mode 100644 index 0000000..944a200 --- /dev/null +++ b/Controllers/DocumentController.cs @@ -0,0 +1,36 @@ +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; + } + } +} diff --git a/Pages/Documents/Details.cshtml b/Pages/Documents/Details.cshtml index 25ec72a..f5e260c 100644 --- a/Pages/Documents/Details.cshtml +++ b/Pages/Documents/Details.cshtml @@ -35,6 +35,6 @@ diff --git a/Pages/Shared/_Layout.cshtml b/Pages/Shared/_Layout.cshtml index 6af4d8d..c87eb01 100644 --- a/Pages/Shared/_Layout.cshtml +++ b/Pages/Shared/_Layout.cshtml @@ -10,7 +10,7 @@