Compare commits

...

2 Commits

Author SHA1 Message Date
564b171e84 Merge pull request 'feat(sales): exponer API de lectura para Delivery Note closes #21' (#22) from feature/leandro/21-deliverynote-api-read into master
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Successful in 1m59s
Reviewed-on: http://saludlab.com.ar:3000/leandro/phronCare/pulls/22
2026-03-19 15:19:36 +00:00
9017097006 feat(sales): exponer API de lectura para Delivery Note closes #21
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (pull_request) Successful in 3m44s
2026-03-19 12:11:30 -03:00
2 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,69 @@
using Domain.Entities;
using Microsoft.AspNetCore.Mvc;
using System.Reflection;
namespace phronCare.API.Controllers.Sales
{
[Route("api/[controller]")]
[ApiController]
public class DeliveryNoteController : ControllerBase
{
private readonly IDeliveryNoteDom _deliveryNoteService;
public DeliveryNoteController(IDeliveryNoteDom deliveryNoteService)
{
_deliveryNoteService = deliveryNoteService ?? throw new ArgumentNullException(nameof(deliveryNoteService));
}
[HttpGet("{id:int}")]
public async Task<ActionResult<EDeliveryNote>> GetById(int id)
{
try
{
var deliveryNote = await _deliveryNoteService.GetByIdAsync(id);
if (deliveryNote == null)
return NotFound($"Remito con ID {id} no encontrado.");
return Ok(deliveryNote);
}
catch (Exception ex)
{
var methodName = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod";
return StatusCode(500, $"{methodName} Message: {ex.Message}");
}
}
[HttpGet("number/{deliveryNoteNumber}")]
public async Task<ActionResult<EDeliveryNote>> GetByDeliveryNoteNumber(string deliveryNoteNumber)
{
try
{
var deliveryNote = await _deliveryNoteService.GetByDeliveryNoteNumberAsync(deliveryNoteNumber);
if (deliveryNote == null)
return NotFound($"Remito con número {deliveryNoteNumber} no encontrado.");
return Ok(deliveryNote);
}
catch (Exception ex)
{
var methodName = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod";
return StatusCode(500, $"{methodName} Message: {ex.Message}");
}
}
[HttpGet("by-quote/{quoteId:int}")]
public async Task<ActionResult<IEnumerable<EDeliveryNote>>> GetByQuoteId(int quoteId)
{
try
{
var deliveryNotes = await _deliveryNoteService.GetByQuoteIdAsync(quoteId);
return Ok(deliveryNotes);
}
catch (Exception ex)
{
var methodName = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod";
return StatusCode(500, $"{methodName} Message: {ex.Message}");
}
}
}
}

View File

@ -238,6 +238,9 @@ static void RepositorysAndServices(WebApplicationBuilder builder)
builder.Services.AddScoped<IAdjustmentReasonDom, AdjustmentReasonService>();
builder.Services.AddScoped<IPhSAdjustmentReasonRepository, PhSAdjustmentReasonRepository>();
builder.Services.AddScoped<IDeliveryNoteDom, DeliveryNoteService>();
builder.Services.AddScoped<IPhSDeliveryNoteRepository, PhSDeliveryNoteRepository>();
builder.Services.AddScoped<ITaxTypeDom, TaxTypeService>();
builder.Services.AddScoped<IPhOhArcataxTypeRepository, PhOhArcataxTypeRepository>();