25 lines
670 B
C#
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();
|
|
}
|
|
}
|
|
|