All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Successful in 6m27s
52 lines
1.9 KiB
C#
52 lines
1.9 KiB
C#
using Core.Interfaces.Stock;
|
|
using Domain.Dtos.Stock;
|
|
using Domain.Entities;
|
|
using Domain.Generics;
|
|
using Models.Interfaces;
|
|
|
|
namespace Core.Services.Stock
|
|
{
|
|
public class ExpeditionService : IExpeditionDom
|
|
{
|
|
#region Declaraciones
|
|
private readonly IExpeditionRepository _repo;
|
|
public ExpeditionService(IExpeditionRepository repo) => _repo = repo;
|
|
#endregion
|
|
#region Guardado completo de expedicion (encabezado + detalles)
|
|
public async Task<(int Id, string ExpeditionNumber)> CreateAndIssueAsync(
|
|
ELSExpeditionHeader header,
|
|
IEnumerable<ELSExpeditionDetail> details,
|
|
int formSeriesId)
|
|
{
|
|
if (header is null) throw new ArgumentNullException(nameof(header));
|
|
if (details is null || !details.Any())
|
|
throw new InvalidOperationException("Debe incluir al menos un ítem.");
|
|
if (formSeriesId <= 0)
|
|
throw new ArgumentOutOfRangeException(nameof(formSeriesId), "Serie inválida.");
|
|
|
|
// Reemplazo directo de la colección (más claro que Clear()+Add)
|
|
header.PhLsmExpeditionDetails = details.ToList();
|
|
|
|
return await _repo.CreateFullExpeditionAsync(header, formSeriesId);
|
|
}
|
|
|
|
public Task<ExpeditionDto?> GetDtoByExpeditionNumberAsync(string expeditionNumber)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
#endregion
|
|
|
|
public Task<PagedResult<ExpeditionDto>> SearchAsync(
|
|
string? expeditionNumber,
|
|
string? status,
|
|
DateTime? issueDateFrom,
|
|
DateTime? issueDateTo,
|
|
int? locationId,
|
|
int page,
|
|
int pageSize)
|
|
=> _repo.SearchAsync(expeditionNumber, status, issueDateFrom, issueDateTo, locationId, page, pageSize);
|
|
public Task<ExpeditionDto?> GetDtoByIdAsync(int id)
|
|
=> _repo.GetDtoByIdAsync(id);
|
|
}
|
|
}
|