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
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (pull_request) Successful in 3m44s
This commit is contained in:
parent
109ef556b9
commit
9017097006
69
phronCare.API/Controllers/Sales/DeliveryNoteController.cs
Normal file
69
phronCare.API/Controllers/Sales/DeliveryNoteController.cs
Normal 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}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -239,6 +239,9 @@ static void RepositorysAndServices(WebApplicationBuilder builder)
|
|||||||
builder.Services.AddScoped<IAdjustmentReasonDom, AdjustmentReasonService>();
|
builder.Services.AddScoped<IAdjustmentReasonDom, AdjustmentReasonService>();
|
||||||
builder.Services.AddScoped<IPhSAdjustmentReasonRepository, PhSAdjustmentReasonRepository>();
|
builder.Services.AddScoped<IPhSAdjustmentReasonRepository, PhSAdjustmentReasonRepository>();
|
||||||
|
|
||||||
|
builder.Services.AddScoped<IDeliveryNoteDom, DeliveryNoteService>();
|
||||||
|
builder.Services.AddScoped<IPhSDeliveryNoteRepository, PhSDeliveryNoteRepository>();
|
||||||
|
|
||||||
builder.Services.AddScoped<ITaxTypeDom, TaxTypeService>();
|
builder.Services.AddScoped<ITaxTypeDom, TaxTypeService>();
|
||||||
builder.Services.AddScoped<IPhOhArcataxTypeRepository, PhOhArcataxTypeRepository>();
|
builder.Services.AddScoped<IPhOhArcataxTypeRepository, PhOhArcataxTypeRepository>();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user