|
|
@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.ComponentModel.DataAnnotations; |
|
|
|
using System.Globalization; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.Extensions.Configuration; |
|
|
|
using Volo.Abp.Application.Dtos; |
|
|
@ -13,6 +14,7 @@ using Volo.Abp.Validation; |
|
|
|
using Win_in.Sfs.Scp.v1.Domain; |
|
|
|
using System.Security.Policy; |
|
|
|
using Volo.Abp.Data; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
|
|
|
|
namespace Win_in.Sfs.Scp.WebApi |
|
|
|
{ |
|
|
@ -31,6 +33,7 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
private readonly ITenantStore _tenantStore; |
|
|
|
private readonly ITenantRepository _tenantRepository; |
|
|
|
private readonly IDataFilter _dataFilter; |
|
|
|
private readonly IOptions<AsnOptions> _options; |
|
|
|
|
|
|
|
public PurchaseOrderAppService( |
|
|
|
IPurchaseOrderRepository repository |
|
|
@ -40,6 +43,7 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
, ITenantStore tenantStore |
|
|
|
, ITenantRepository tenantRepository |
|
|
|
, IDataFilter dataFilter |
|
|
|
, IOptions<AsnOptions> options |
|
|
|
) : base(repository) |
|
|
|
{ |
|
|
|
_purchaseOrderRepository = repository; |
|
|
@ -49,6 +53,7 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
_tenantStore = tenantStore; |
|
|
|
_tenantRepository = tenantRepository; |
|
|
|
_dataFilter = dataFilter; |
|
|
|
_options = options; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -105,6 +110,8 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
Validator.CheckSite(_tenantRepository, entity.Site); |
|
|
|
Validator.CheckSite(_tenantRepository, entity.Company); |
|
|
|
|
|
|
|
if (entity.PoNumber.StartsWith(_options.Value.ValidPoPre, true, CultureInfo.CurrentCulture)) |
|
|
|
{ |
|
|
|
var tenant = await _tenantStore.FindAsync(entity.Site); |
|
|
|
using (CurrentTenant.Change(tenant.Id, tenant.Name)) |
|
|
|
{ |
|
|
@ -113,12 +120,16 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
|
|
|
|
Validator.CheckSupplierCode(_taVenderRepository, entity.Site, entity.SupplierCode); |
|
|
|
|
|
|
|
|
|
|
|
await UpsertTbPoAndTbPoDetailAsync(entity, tenant.Id); |
|
|
|
await CurrentUnitOfWork.SaveChangesAsync(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
entity.ErrorMessage = $"'{entity.PoNumber}' is not start with '{_options.Value.ValidPoPre}',ignore."; |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
var baseEx = ex.GetBaseException(); |
|
|
|