using Microsoft.AspNetCore.Mvc; using GrossesMitainesAPI.Models; using System.Linq; using GrossesMitainesAPI.Data; using Microsoft.Extensions.Logging; namespace GrossesMitainesAPI.Controllers; [ApiController, Route("api/[controller]")] public class InventoryController : Controller { private readonly ILogger _logger; private readonly InventoryContext _context; public InventoryController(ILogger logger, InventoryContext context) { _logger = logger; _context = context; } [HttpGet(Name ="Inventory")] public IEnumerable Get(int? last) { if (!last.HasValue) last = 1; return _context.Products.Where(x => x.Id >= last && x.Id < last + 5).ToList(); } }