|
@ -89,14 +89,14 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
|
|
|
|
|
[HttpGet] |
|
|
[HttpGet] |
|
|
[Route("between-id")] |
|
|
[Route("between-id")] |
|
|
public async Task<List<X12AsnDTO>> GetListAsync(long beginUid, long endUid) |
|
|
public async Task<List<X12AsnDTO>> GetListAsync(string site, long beginUid, long endUid) |
|
|
{ |
|
|
{ |
|
|
if (endUid < beginUid) |
|
|
if (endUid < beginUid) |
|
|
{ |
|
|
{ |
|
|
throw new BadHttpRequestException("beginUid is bigger than endUid"); |
|
|
throw new BadHttpRequestException("beginUid is bigger than endUid"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var entities = await _x12AsnRepository.GetListAsync(p => p.UID >= beginUid && p.UID <= endUid); |
|
|
var entities = await _x12AsnRepository.GetListAsync(p => p.Site == site && p.UID >= beginUid && p.UID <= endUid); |
|
|
|
|
|
|
|
|
var dtos = BuildDtos(entities); |
|
|
var dtos = BuildDtos(entities); |
|
|
|
|
|
|
|
@ -106,14 +106,14 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
|
|
|
|
|
[HttpGet] |
|
|
[HttpGet] |
|
|
[Route("between-date")] |
|
|
[Route("between-date")] |
|
|
public async Task<List<X12AsnDTO>> GetListAsync(DateTime beginDate, DateTime endDate) |
|
|
public async Task<List<X12AsnDTO>> GetListAsync(string site, DateTime beginDate, DateTime endDate) |
|
|
{ |
|
|
{ |
|
|
if (endDate < beginDate) |
|
|
if (endDate < beginDate) |
|
|
{ |
|
|
{ |
|
|
throw new BadHttpRequestException("beginDate is after endDate"); |
|
|
throw new BadHttpRequestException("beginDate is after endDate"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var entities = await _x12AsnRepository.GetListAsync(p => p.EffectiveDate >= beginDate && p.EffectiveDate <= endDate); |
|
|
var entities = await _x12AsnRepository.GetListAsync(p => p.Site == site && p.EffectiveDate >= beginDate && p.EffectiveDate <= endDate); |
|
|
|
|
|
|
|
|
var dtos = BuildDtos(entities); |
|
|
var dtos = BuildDtos(entities); |
|
|
|
|
|
|
|
@ -122,13 +122,13 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
|
|
|
|
|
[HttpGet] |
|
|
[HttpGet] |
|
|
[Route("by-id")] |
|
|
[Route("by-id")] |
|
|
public async Task<X12AsnDTO> GetAsync(long uid) |
|
|
public async Task<X12AsnDTO> GetAsync(string site, long uid) |
|
|
{ |
|
|
{ |
|
|
var entity = await _x12AsnRepository.FirstOrDefaultAsync(p => p.UID == uid); |
|
|
var entity = await _x12AsnRepository.FirstOrDefaultAsync(p => p.Site == site && p.UID == uid); |
|
|
|
|
|
|
|
|
if (entity == null) |
|
|
if (entity == null) |
|
|
{ |
|
|
{ |
|
|
throw new BadHttpRequestException($"ASN of {uid} is not found"); |
|
|
throw new BadHttpRequestException($"ASN of {uid} in {site} is not found"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var dto = BuildDto(entity); |
|
|
var dto = BuildDto(entity); |
|
@ -138,13 +138,13 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
|
|
|
|
|
[HttpGet] |
|
|
[HttpGet] |
|
|
[Route("by-number")] |
|
|
[Route("by-number")] |
|
|
public async Task<X12AsnDTO> GetAsync(string number) |
|
|
public async Task<X12AsnDTO> GetAsync(string site, string number) |
|
|
{ |
|
|
{ |
|
|
var entity = await _x12AsnRepository.FirstOrDefaultAsync(p => p.BillNum == number); |
|
|
var entity = await _x12AsnRepository.FirstOrDefaultAsync(p => p.Site == site && p.BillNum == number); |
|
|
|
|
|
|
|
|
if (entity == null) |
|
|
if (entity == null) |
|
|
{ |
|
|
{ |
|
|
throw new BadHttpRequestException($"ASN of {number} is not found"); |
|
|
throw new BadHttpRequestException($"ASN of {number} in {site} is not found"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var dto = BuildDto(entity); |
|
|
var dto = BuildDto(entity); |
|
@ -155,14 +155,14 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
|
|
|
|
|
[HttpPost] |
|
|
[HttpPost] |
|
|
[Route("update-status")] |
|
|
[Route("update-status")] |
|
|
public async Task<X12AsnDTO> UpdateStatusAsync(string number, EnumExchangeDataStatus status) |
|
|
public async Task<X12AsnDTO> UpdateStatusAsync(string site, string number, EnumExchangeDataStatus status) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
var entity = await _x12AsnRepository.FirstOrDefaultAsync(p => p.BillNum == number); |
|
|
var entity = await _x12AsnRepository.FirstOrDefaultAsync(p => p.Site == site && p.BillNum == number); |
|
|
|
|
|
|
|
|
if (entity == null) |
|
|
if (entity == null) |
|
|
{ |
|
|
{ |
|
|
throw new BadHttpRequestException($"ASN of {number} is not found"); |
|
|
throw new BadHttpRequestException($"ASN of {number} in {site} is not found"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var result = await _x12AsnRepository.UpdateStatusAsync(entity.Id, status); |
|
|
var result = await _x12AsnRepository.UpdateStatusAsync(entity.Id, status); |
|
|