GGMM/GrossesMitaines/GrossesMitainesAPI/Controllers/InventoryController.cs

25 lines
670 B
C#
Raw Normal View History

2022-10-08 13:22:12 -04:00
using Microsoft.AspNetCore.Mvc;
using GrossesMitainesAPI.Models;
using System.Linq;
using GrossesMitainesAPI.Data;
using Microsoft.Extensions.Logging;
namespace GrossesMitainesAPI.Controllers;
2022-10-08 15:04:29 -04:00
[ApiController, Route("api/[controller]")]
2022-10-08 13:22:12 -04:00
public class InventoryController : Controller {
private readonly InventoryContext _context;
2022-10-08 16:05:23 -04:00
public InventoryController(InventoryContext context) {
2022-10-08 13:22:12 -04:00
_context = context;
}
[HttpGet(Name ="Inventory")]
2022-10-08 16:05:23 -04:00
public IEnumerable<Product> Get(int? lastId) {
if (!lastId.HasValue)
lastId = 1;
return _context.Products.Where(x => x.Id >= lastId && x.Id < lastId + 5).ToList();
2022-10-08 13:22:12 -04:00
}
}