|
@ -97,14 +97,15 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
Validator.CheckSite(_tenantRepository, entity.Site); |
|
|
Validator.CheckSite(_tenantRepository, entity.Site); |
|
|
Validator.CheckSite(_tenantRepository, entity.Company); |
|
|
Validator.CheckSite(_tenantRepository, entity.Company); |
|
|
var tenant = await _tenantStore.FindAsync(entity.Site); |
|
|
var tenant = await _tenantStore.FindAsync(entity.Site); |
|
|
|
|
|
bool flag = true; |
|
|
using (CurrentTenant.Change(tenant.Id, tenant.Name)) |
|
|
using (CurrentTenant.Change(tenant.Id, tenant.Name)) |
|
|
{ |
|
|
{ |
|
|
using (_dataFilter.Disable<IMultiTenant>()) |
|
|
using (_dataFilter.Disable<IMultiTenant>()) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
Validator.CheckSupplierCode(_taVenderRepository, entity.Site, entity.SupplierCode); |
|
|
Validator.CheckSupplierCode(_taVenderRepository, entity.Site, entity.SupplierCode); |
|
|
|
|
|
flag = await _tbReceiptRepository.GetCountAsync(ObjectMapper.Map<Receipt, TB_RECEIVE_QAD>(entity)); |
|
|
await UpsertTbReceiptAndTbReceiptDetailAsync(entity, tenant.Id); |
|
|
await UpsertTbReceiptAndTbReceiptDetailAsync(entity, tenant.Id, flag); |
|
|
await CurrentUnitOfWork.SaveChangesAsync(); |
|
|
await CurrentUnitOfWork.SaveChangesAsync(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -133,15 +134,17 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private async Task UpsertTbReceiptAndTbReceiptDetailAsync(Receipt entity, Guid tenantId) |
|
|
private async Task UpsertTbReceiptAndTbReceiptDetailAsync(Receipt entity, Guid tenantId,bool flag) |
|
|
{ |
|
|
{ |
|
|
//使用AutoMapper执行类型转换
|
|
|
//使用AutoMapper执行类型转换
|
|
|
var tbReceipt = ObjectMapper.Map<Receipt, TB_RECEIVE_QAD>(entity); |
|
|
var tbReceipt = ObjectMapper.Map<Receipt, TB_RECEIVE_QAD>(entity); |
|
|
var tbReceiveDetail = ObjectMapper.Map<Receipt, TB_RECEIVE_DETAIL_QAD>(entity); |
|
|
var tbReceiveDetail = ObjectMapper.Map<Receipt, TB_RECEIVE_DETAIL_QAD>(entity); |
|
|
|
|
|
|
|
|
tbReceipt.TenantId = tenantId; |
|
|
tbReceipt.TenantId = tenantId; |
|
|
|
|
|
if (flag) |
|
|
|
|
|
{ |
|
|
//根据传入数据新增或修改SCP数据
|
|
|
//根据传入数据新增或修改SCP数据
|
|
|
await _tbReceiptRepository.UpsertAsync(tbReceipt); |
|
|
await _tbReceiptRepository.UpsertAsync(tbReceipt); |
|
|
|
|
|
} |
|
|
tbReceiveDetail.TenantId = tenantId; |
|
|
tbReceiveDetail.TenantId = tenantId; |
|
|
//根据传入数据新增或修改SCP数据
|
|
|
//根据传入数据新增或修改SCP数据
|
|
|
await _tbReceiptDetailRepository.UpsertAsync(tbReceiveDetail); |
|
|
await _tbReceiptDetailRepository.UpsertAsync(tbReceiveDetail); |
|
|