GGMM/GrossesMitaines/GrossesMitainesAPI/Controllers/InventoryController.cs
2022-10-08 13:05:23 -07:00

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