* Introduced new WzRowMareli service to handle new client

This commit is contained in:
2025-09-08 21:19:17 +02:00
parent f45baa31a5
commit 89792d3d28
8 changed files with 201 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
using Microsoft.AspNetCore.Mvc;
using SytelineSaAppEfDataModel.Dtos;
using SytelineSaAppEfDataModel.Services;
namespace FaKrosnoApi.Controllers;
[ApiController]
[Route("api/[controller]")]
public class WzRowMareliController(IWzRowMareliService service, IMaterialTransactionService materialTransactionService) : Controller
{
[HttpGet]
public async Task<ActionResult<IEnumerable<WzRowMareliDto>>> GetAll()
{
IEnumerable<WzRowMareliDto> wzRows = await service.GetAll();
return Ok(wzRows);
}
[HttpPost]
public async Task<ActionResult> CreateRows([FromBody] IEnumerable<WzRowMareliDto> 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<WzRowMareliDto>>> GetByWzHeaderId(Guid wzHeaderId)
{
IEnumerable<WzRowMareliDto> 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<WzRowMareliDto> rows)
{
if (rows == null || !rows.Any())
{
return BadRequest("No rows provided.");
}
await service.UpdateRows(rows);
return NoContent();
}
}

View File

@@ -109,6 +109,7 @@ builder.Services.AddScoped<IItemService, ItemService>();
builder.Services.AddScoped<IVatCodeAssociationService, VatCodeAssociationService>();
builder.Services.AddScoped<IItemCustPriceAllService, ItemCustPriceAllService>();
builder.Services.AddScoped<IEdiLogService, EdiLogService>();
builder.Services.AddScoped<IWzRowMareliService, WzRowMareliService>();
builder.Services.AddHostedService<TimedHostedService>();