31 lines
879 B
C#
31 lines
879 B
C#
using FaKrosnoEfDataModel.Dtos;
|
|
using FaKrosnoEfDataModel.Services;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace FaKrosnoApi.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
public class ProductController(IProductService service) : Controller
|
|
{
|
|
[HttpGet]
|
|
public async Task<ActionResult<IEnumerable<ProductDto>>> GetAll()
|
|
{
|
|
IEnumerable<ProductDto?> products = await service.GetEntities();
|
|
return Ok(products);
|
|
}
|
|
|
|
[HttpGet("by-index")]
|
|
public async Task<ActionResult<IEnumerable<ProductDto>>> GetByIndex([FromQuery] string indexName)
|
|
{
|
|
IEnumerable<ProductDto?> products = await service.GetEntitiesToFix(indexName);
|
|
return Ok(products);
|
|
}
|
|
|
|
[HttpPut]
|
|
public async Task<ActionResult> Update([FromBody] ProductDto product)
|
|
{
|
|
await service.UpdateEntity(product);
|
|
return Ok();
|
|
}
|
|
} |