GGMM/GrossesMitaines/GrossesMitainesAPI/Controllers/InventoryController.cs
2022-10-08 12:04:29 -07:00

27 lines
782 B
C#

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<InventoryController> _logger;
private readonly InventoryContext _context;
public InventoryController(ILogger<InventoryController> logger, InventoryContext context) {
_logger = logger;
_context = context;
}
[HttpGet(Name ="Inventory")]
public IEnumerable<Product> Get(int? last) {
if (!last.HasValue)
last = 1;
return _context.Products.Where(x => x.Id >= last && x.Id < last + 5).ToList();
}
}