62 lines
2.0 KiB
C#
62 lines
2.0 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using SytelineSaAppEfDataModel.Dtos;
|
|
using SytelineSaAppEfDataModel.Services;
|
|
|
|
namespace FaKrosnoApi.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
public class WzRowMeyleController(IWzRowMeyleService service, IMaterialTransactionService materialTransactionService) : Controller
|
|
{
|
|
[HttpGet]
|
|
public async Task<ActionResult<IEnumerable<WzRowMeyleDto>>> GetAll()
|
|
{
|
|
IEnumerable<WzRowMeyleDto> wzRows = await service.GetAll();
|
|
return Ok(wzRows);
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<ActionResult> CreateRows([FromBody] IEnumerable<WzRowMeyleDto> rows)
|
|
{
|
|
if (rows == null || !rows.Any())
|
|
{
|
|
return BadRequest("No rows provided.");
|
|
}
|
|
|
|
await service.CreateRows(rows);
|
|
return CreatedAtAction(nameof(GetAll), new { count = rows.Count() }, rows);
|
|
}
|
|
|
|
[HttpGet("by-wz-header-id")]
|
|
public async Task<ActionResult<IEnumerable<WzRowMeyleDto>>> GetByWzHeaderId(Guid wzHeaderId)
|
|
{
|
|
IEnumerable<WzRowMeyleDto> wzRows = await service.GetByWzHeaderId(wzHeaderId);
|
|
return Ok(wzRows);
|
|
}
|
|
|
|
[HttpGet("by-part-number")]
|
|
public async Task<ActionResult<MaterialTransactionDto>> GetByPartNumber([FromQuery] string partNumber)
|
|
{
|
|
MaterialTransactionDto materialTransaction = await materialTransactionService.GetByPartNumber(partNumber);
|
|
return Ok(materialTransaction);
|
|
}
|
|
|
|
[HttpGet("transactions-with-part-number")]
|
|
public async Task<ActionResult<MaterialTransactionDto>> GetTransactionsWithPartNumber()
|
|
{
|
|
IEnumerable<MaterialTransactionDto> materialTransactions = await materialTransactionService.GetWithPartNumber();
|
|
return Ok(materialTransactions);
|
|
}
|
|
|
|
[HttpPut]
|
|
public async Task<ActionResult> UpdateRows([FromBody] IEnumerable<WzRowMeyleDto> rows)
|
|
{
|
|
if (rows == null || !rows.Any())
|
|
{
|
|
return BadRequest("No rows provided.");
|
|
}
|
|
|
|
await service.UpdateRows(rows);
|
|
return NoContent();
|
|
}
|
|
} |