Browse Source

[fix]使用租户信息进行Site验证

master
贾荣国Home 3 years ago
parent
commit
06f251259e
  1. 23
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Parts/PartAppService.cs
  2. 33
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/PurchaseOrders/PurchaseOrderAppService.cs
  3. 39
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Receipts/ReceiptAppService.cs
  4. 31
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Suppliers/SuppliersAppService.cs
  5. 28
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/UnplannedReceipts/UnplannedReceiptAppService.cs
  6. 23
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Validator.cs
  7. 2
      WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Parts/TA_PART.cs
  8. 2
      WebApiService/src/Win_in.Sfs.Scp.v1.Domain/PurchaseOrders/TB_PO.cs
  9. 2
      WebApiService/src/Win_in.Sfs.Scp.v1.Domain/PurchaseOrders/TB_PO_DETAIL.cs
  10. 2
      WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Receipts/TB_RECEIVE_DETAIL_QAD.cs
  11. 2
      WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Receipts/TB_RECEIVE_QAD.cs
  12. 2
      WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Suppliers/TA_VENDER.cs

23
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Parts/PartAppService.cs

@ -35,19 +35,19 @@ namespace Win_in.Sfs.Scp.WebApi
private readonly IPartRepository _partRepository; private readonly IPartRepository _partRepository;
private readonly ITaPartRepository _taPartRepository; private readonly ITaPartRepository _taPartRepository;
private readonly ITenantStore _tenantStore; private readonly ITenantStore _tenantStore;
private readonly string _validSites = Validator.VALID_SITES; private readonly ITenantRepository _tenantRepository;
public PartAppService( public PartAppService(
IPartRepository repository IPartRepository repository
, ITaPartRepository taPartRepository , ITaPartRepository taPartRepository
, ITenantStore tenantStore , ITenantStore tenantStore
, IConfiguration configuration , ITenantRepository tenantRepository
) : base(repository) ) : base(repository)
{ {
_partRepository = repository; _partRepository = repository;
_taPartRepository = taPartRepository; _taPartRepository = taPartRepository;
_tenantStore = tenantStore; _tenantStore = tenantStore;
_validSites = configuration["ValidSites"]; _tenantRepository = tenantRepository;
} }
/// <summary> /// <summary>
@ -89,11 +89,15 @@ namespace Win_in.Sfs.Scp.WebApi
try try
{ {
Validator.CheckSite(_validSites, entity.Site); Validator.CheckSite(_tenantRepository, entity.Site);
Validator.CheckSite(_validSites, entity.Company); Validator.CheckSite(_tenantRepository, entity.Company);
await UpsertTaPartAsync(entity); var tenant = await _tenantStore.FindAsync(entity.Site);
using (CurrentTenant.Change(tenant.Id, tenant.Name))
{
await UpsertTaPartAsync(entity, tenant.Id);
await CurrentUnitOfWork.SaveChangesAsync(); await CurrentUnitOfWork.SaveChangesAsync();
} }
}
catch (Exception ex) catch (Exception ex)
{ {
var baseEx = ex.GetBaseException(); var baseEx = ex.GetBaseException();
@ -118,17 +122,14 @@ namespace Win_in.Sfs.Scp.WebApi
} }
} }
private async Task UpsertTaPartAsync(Part entity) private async Task UpsertTaPartAsync(Part entity, Guid tenantId)
{ {
//使用AutoMapper执行类型转换 //使用AutoMapper执行类型转换
var taPart = ObjectMapper.Map<Part, TA_PART>(entity); var taPart = ObjectMapper.Map<Part, TA_PART>(entity);
var tenant =await _tenantStore.FindAsync(taPart.Site); taPart.TenantId = tenantId;
using (CurrentTenant.Change(tenant.Id,tenant.Name))
{
//根据传入数据新增或修改SCP数据 //根据传入数据新增或修改SCP数据
await _taPartRepository.UpsertAsync(taPart); await _taPartRepository.UpsertAsync(taPart);
} }
} }
}
} }

33
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/PurchaseOrders/PurchaseOrderAppService.cs

@ -11,6 +11,7 @@ using Volo.Abp.MultiTenancy;
using Volo.Abp.TenantManagement; using Volo.Abp.TenantManagement;
using Volo.Abp.Validation; using Volo.Abp.Validation;
using Win_in.Sfs.Scp.v1.Domain; using Win_in.Sfs.Scp.v1.Domain;
using System.Security.Policy;
namespace Win_in.Sfs.Scp.WebApi namespace Win_in.Sfs.Scp.WebApi
{ {
@ -27,7 +28,7 @@ namespace Win_in.Sfs.Scp.WebApi
private readonly ITbPoDetailRepository _tbPoDetailRepository; private readonly ITbPoDetailRepository _tbPoDetailRepository;
private readonly ITaVenderRepository _taVenderRepository; private readonly ITaVenderRepository _taVenderRepository;
private readonly ITenantStore _tenantStore; private readonly ITenantStore _tenantStore;
private readonly string _validSites = Validator.VALID_SITES; private readonly ITenantRepository _tenantRepository;
public PurchaseOrderAppService( public PurchaseOrderAppService(
IPurchaseOrderRepository repository IPurchaseOrderRepository repository
@ -35,7 +36,7 @@ namespace Win_in.Sfs.Scp.WebApi
, ITbPoDetailRepository tbPoDetailRepository , ITbPoDetailRepository tbPoDetailRepository
, ITaVenderRepository taVenderRepository , ITaVenderRepository taVenderRepository
, ITenantStore tenantStore , ITenantStore tenantStore
, IConfiguration configuration , ITenantRepository tenantRepository
) : base(repository) ) : base(repository)
{ {
_purchaseOrderRepository = repository; _purchaseOrderRepository = repository;
@ -43,7 +44,7 @@ namespace Win_in.Sfs.Scp.WebApi
_tbPoDetailRepository = tbPoDetailRepository; _tbPoDetailRepository = tbPoDetailRepository;
_taVenderRepository = taVenderRepository; _taVenderRepository = taVenderRepository;
_tenantStore = tenantStore; _tenantStore = tenantStore;
_validSites = configuration["ValidSites"]; _tenantRepository = tenantRepository;
} }
@ -95,12 +96,18 @@ namespace Win_in.Sfs.Scp.WebApi
try try
{ {
Validator.CheckSite(_validSites,entity.Site); Validator.CheckSite(_tenantRepository, entity.Site);
Validator.CheckSite(_validSites,entity.Company); Validator.CheckSite(_tenantRepository, entity.Company);
Validator.CheckSupplierCode(_taVenderRepository,entity.Site, entity.SupplierCode);
await UpsertTbPoAndTbPoDetailAsync(entity); var tenant = await _tenantStore.FindAsync(entity.Site);
await CurrentUnitOfWork.SaveChangesAsync(); using (CurrentTenant.Change(tenant.Id, tenant.Name))
{
Validator.CheckSupplierCode(_taVenderRepository, entity.Site, entity.SupplierCode);
await UpsertTbPoAndTbPoDetailAsync(entity, tenant.Id);
await CurrentUnitOfWork.SaveChangesAsync();
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -124,13 +131,12 @@ namespace Win_in.Sfs.Scp.WebApi
} }
} }
private async Task UpsertTbPoAndTbPoDetailAsync(PurchaseOrder entity) private async Task UpsertTbPoAndTbPoDetailAsync(PurchaseOrder entity, Guid tenantId)
{ {
//使用AutoMapper执行类型转换 //使用AutoMapper执行类型转换
var tbPo = ObjectMapper.Map<PurchaseOrder, TB_PO>(entity); var tbPo = ObjectMapper.Map<PurchaseOrder, TB_PO>(entity);
var tenant =await _tenantStore.FindAsync(tbPo.Site); tbPo.TenantId = tenantId;
using (CurrentTenant.Change(tenant.Id, tenant.Name))
{
//根据传入数据新增或修改SCP数据 //根据传入数据新增或修改SCP数据
await _tbPoRepository.UpsertAsync(tbPo); await _tbPoRepository.UpsertAsync(tbPo);
@ -144,10 +150,11 @@ namespace Win_in.Sfs.Scp.WebApi
tbPoDetail.Site = tbPo.Site; tbPoDetail.Site = tbPo.Site;
tbPoDetail.BeginTime = tbPo.BeginTime; tbPoDetail.BeginTime = tbPo.BeginTime;
tbPoDetail.EndTime = tbPo.EndTime; tbPoDetail.EndTime = tbPo.EndTime;
tbPoDetail.TenantId = tenantId;
//根据传入数据新增或修改SCP数据 //根据传入数据新增或修改SCP数据
await _tbPoDetailRepository.UpsertAsync(tbPoDetail); await _tbPoDetailRepository.UpsertAsync(tbPoDetail);
} }
}
} }
} }
} }

39
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Receipts/ReceiptAppService.cs

@ -11,6 +11,7 @@ using Volo.Abp.MultiTenancy;
using Volo.Abp.Uow; using Volo.Abp.Uow;
using Volo.Abp.Validation; using Volo.Abp.Validation;
using Win_in.Sfs.Scp.v1.Domain; using Win_in.Sfs.Scp.v1.Domain;
using Volo.Abp.TenantManagement;
namespace Win_in.Sfs.Scp.WebApi namespace Win_in.Sfs.Scp.WebApi
{ {
@ -20,22 +21,22 @@ namespace Win_in.Sfs.Scp.WebApi
[Authorize] [Authorize]
[Route(RouteConsts.Receipt)] [Route(RouteConsts.Receipt)]
[ApiExplorerSettings(GroupName = SwaggerGroupConsts.ScpWebApi)] [ApiExplorerSettings(GroupName = SwaggerGroupConsts.ScpWebApi)]
public class ReceiptAppService : ReadOnlyAppService<Receipt, ReceiptDTO, Guid,RequestDTO>, IReceiptAppService public class ReceiptAppService : ReadOnlyAppService<Receipt, ReceiptDTO, Guid, RequestDTO>, IReceiptAppService
{ {
private readonly IReceiptRepository _receiptRepository; private readonly IReceiptRepository _receiptRepository;
private readonly ITbReceiptRepository _tbReceiptRepository; private readonly ITbReceiptRepository _tbReceiptRepository;
private readonly ITbReceiptDetailRepository _tbReceiptDetailRepository; private readonly ITbReceiptDetailRepository _tbReceiptDetailRepository;
private readonly ITaVenderRepository _taVenderRepository; private readonly ITaVenderRepository _taVenderRepository;
private readonly ITenantStore _tenantStore; private readonly ITenantStore _tenantStore;
private readonly string _validSites = Validator.VALID_SITES; private readonly ITenantRepository _tenantRepository;
public ReceiptAppService( public ReceiptAppService(
IReceiptRepository repository IReceiptRepository repository
,ITbReceiptRepository tbReceiptRepository , ITbReceiptRepository tbReceiptRepository
,ITbReceiptDetailRepository tbReceiptDetailRepository , ITbReceiptDetailRepository tbReceiptDetailRepository
,ITaVenderRepository taVenderRepository , ITaVenderRepository taVenderRepository
, ITenantStore tenantStore , ITenantStore tenantStore
, IConfiguration configuration , ITenantRepository tenantRepository
) : base(repository) ) : base(repository)
{ {
_receiptRepository = repository; _receiptRepository = repository;
@ -43,8 +44,7 @@ namespace Win_in.Sfs.Scp.WebApi
_tbReceiptDetailRepository = tbReceiptDetailRepository; _tbReceiptDetailRepository = tbReceiptDetailRepository;
_taVenderRepository = taVenderRepository; _taVenderRepository = taVenderRepository;
_tenantStore = tenantStore; _tenantStore = tenantStore;
_validSites = configuration["ValidSites"]; _tenantRepository = tenantRepository;
} }
@ -88,12 +88,16 @@ namespace Win_in.Sfs.Scp.WebApi
try try
{ {
Validator.CheckSite(_validSites,entity.Site); Validator.CheckSite(_tenantRepository, entity.Site);
Validator.CheckSite(_validSites,entity.Company); Validator.CheckSite(_tenantRepository, entity.Company);
Validator.CheckSupplierCode(_taVenderRepository,entity.Site, entity.SupplierCode); var tenant = await _tenantStore.FindAsync(entity.Site);
await UpsertTbReceiptAndTbReceiptDetailAsync(entity); using (CurrentTenant.Change(tenant.Id, tenant.Name))
await CurrentUnitOfWork.SaveChangesAsync(); {
Validator.CheckSupplierCode(_taVenderRepository, entity.Site, entity.SupplierCode);
await UpsertTbReceiptAndTbReceiptDetailAsync(entity, tenant.Id);
await CurrentUnitOfWork.SaveChangesAsync();
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -119,21 +123,18 @@ namespace Win_in.Sfs.Scp.WebApi
} }
} }
private async Task UpsertTbReceiptAndTbReceiptDetailAsync(Receipt entity) private async Task UpsertTbReceiptAndTbReceiptDetailAsync(Receipt entity, Guid tenantId)
{ {
//使用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);
var tenant = await _tenantStore.FindAsync(tbReceipt.Site); tbReceipt.TenantId = tenantId;
using (CurrentTenant.Change(tenant.Id, tenant.Name))
{
//根据传入数据新增或修改SCP数据 //根据传入数据新增或修改SCP数据
await _tbReceiptRepository.UpsertAsync(tbReceipt); await _tbReceiptRepository.UpsertAsync(tbReceipt);
tbReceiveDetail.TenantId = tenantId;
//根据传入数据新增或修改SCP数据 //根据传入数据新增或修改SCP数据
await _tbReceiptDetailRepository.UpsertAsync(tbReceiveDetail); await _tbReceiptDetailRepository.UpsertAsync(tbReceiveDetail);
} }
} }
}
} }

31
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Suppliers/SuppliersAppService.cs

@ -9,6 +9,7 @@ using Microsoft.Extensions.Configuration;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
using Volo.Abp.TenantManagement;
using Volo.Abp.Uow; using Volo.Abp.Uow;
using Volo.Abp.Validation; using Volo.Abp.Validation;
using Win_in.Sfs.Scp.v1.Domain; using Win_in.Sfs.Scp.v1.Domain;
@ -22,25 +23,24 @@ namespace Win_in.Sfs.Scp.WebApi
[Authorize] [Authorize]
[Route(RouteConsts.Supplier)] [Route(RouteConsts.Supplier)]
[ApiExplorerSettings(GroupName = SwaggerGroupConsts.ScpWebApi)] [ApiExplorerSettings(GroupName = SwaggerGroupConsts.ScpWebApi)]
public class SuppliersAppService : ReadOnlyAppService<Supplier, SupplierDTO, Guid,RequestDTO>, ISupplierAppService public class SuppliersAppService : ReadOnlyAppService<Supplier, SupplierDTO, Guid, RequestDTO>, ISupplierAppService
{ {
private readonly ISupplierRepository _supplierRepository; private readonly ISupplierRepository _supplierRepository;
private readonly ITaVenderRepository _taVenderRepository; private readonly ITaVenderRepository _taVenderRepository;
private readonly ITenantStore _tenantStore; private readonly ITenantStore _tenantStore;
private readonly string _validSites = Validator.VALID_SITES; private readonly ITenantRepository _tenantRepository;
public SuppliersAppService( public SuppliersAppService(
ISupplierRepository repository ISupplierRepository repository
,ITaVenderRepository taVenderRepository , ITaVenderRepository taVenderRepository
,ITenantStore tenantStore , ITenantStore tenantStore
, IConfiguration configuration , ITenantRepository tenantRepository
) : base(repository) ) : base(repository)
{ {
_supplierRepository = repository; _supplierRepository = repository;
_taVenderRepository = taVenderRepository; _taVenderRepository = taVenderRepository;
_tenantStore = tenantStore; _tenantStore = tenantStore;
_validSites = configuration["ValidSites"]; _tenantRepository = tenantRepository;
} }
@ -83,10 +83,13 @@ namespace Win_in.Sfs.Scp.WebApi
try try
{ {
Validator.CheckSite(_validSites,entity.Company); Validator.CheckSite(_tenantRepository, entity.Company);
UpsertTaVenderAsync(entity).Wait(); var tenant = await _tenantStore.FindAsync(entity.Company);
using (CurrentTenant.Change(tenant.Id, tenant.Name))
{
await UpsertTaVenderAsync(entity, tenant.Id);
await CurrentUnitOfWork.SaveChangesAsync(); await CurrentUnitOfWork.SaveChangesAsync();
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -111,18 +114,14 @@ namespace Win_in.Sfs.Scp.WebApi
} }
} }
private async Task UpsertTaVenderAsync(Supplier entity) private async Task UpsertTaVenderAsync(Supplier entity, Guid tenantId)
{ {
//使用AutoMapper执行类型转换 //使用AutoMapper执行类型转换
var taVender = ObjectMapper.Map<Supplier, TA_VENDER>(entity); var taVender = ObjectMapper.Map<Supplier, TA_VENDER>(entity);
var tenant =await _tenantStore.FindAsync(taVender.Site); taVender.TenantId = tenantId;
using (CurrentTenant.Change(tenant.Id, tenant.Name))
{
//根据传入数据新增或修改SCP数据 //根据传入数据新增或修改SCP数据
await _taVenderRepository.UpsertAsync(taVender); await _taVenderRepository.UpsertAsync(taVender);
} }
} }
}
} }

28
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/UnplannedReceipts/UnplannedReceiptAppService.cs

@ -12,6 +12,7 @@ using Volo.Abp.MultiTenancy;
using Volo.Abp.Uow; using Volo.Abp.Uow;
using Volo.Abp.Validation; using Volo.Abp.Validation;
using Win_in.Sfs.Scp.v1.Domain; using Win_in.Sfs.Scp.v1.Domain;
using Volo.Abp.TenantManagement;
namespace Win_in.Sfs.Scp.WebApi namespace Win_in.Sfs.Scp.WebApi
{ {
@ -29,7 +30,7 @@ namespace Win_in.Sfs.Scp.WebApi
private readonly ITbReceiptDetailRepository _tbReceiptDetailRepository; private readonly ITbReceiptDetailRepository _tbReceiptDetailRepository;
private readonly ITaVenderRepository _taVenderRepository; private readonly ITaVenderRepository _taVenderRepository;
private readonly ITenantStore _tenantStore; private readonly ITenantStore _tenantStore;
private readonly string _validSites = Validator.VALID_SITES; private readonly ITenantRepository _tenantRepository;
public UnplannedReceiptAppService( public UnplannedReceiptAppService(
IUnplannedReceiptRepository repository IUnplannedReceiptRepository repository
@ -37,7 +38,7 @@ namespace Win_in.Sfs.Scp.WebApi
, ITbReceiptDetailRepository tbReceiptDetailRepository , ITbReceiptDetailRepository tbReceiptDetailRepository
, ITaVenderRepository taVenderRepository , ITaVenderRepository taVenderRepository
, ITenantStore tenantStore , ITenantStore tenantStore
, IConfiguration configuration , ITenantRepository tenantRepository
) : base(repository) ) : base(repository)
{ {
_unplannedReceiptRepository = repository; _unplannedReceiptRepository = repository;
@ -45,8 +46,7 @@ namespace Win_in.Sfs.Scp.WebApi
_tbReceiptDetailRepository = tbReceiptDetailRepository; _tbReceiptDetailRepository = tbReceiptDetailRepository;
_taVenderRepository = taVenderRepository; _taVenderRepository = taVenderRepository;
_tenantStore = tenantStore; _tenantStore = tenantStore;
_validSites = configuration["ValidSites"]; _tenantRepository = tenantRepository;
} }
@ -90,13 +90,16 @@ namespace Win_in.Sfs.Scp.WebApi
try try
{ {
Validator.CheckSite(_validSites, entity.Site); Validator.CheckSite(_tenantRepository, entity.Site);
Validator.CheckSite(_validSites, entity.Company); Validator.CheckSite(_tenantRepository, entity.Company);
var tenant = await _tenantStore.FindAsync(entity.Site);
using (CurrentTenant.Change(tenant.Id, tenant.Name))
{
Validator.CheckSupplierCode(_taVenderRepository, entity.Site, entity.Address); Validator.CheckSupplierCode(_taVenderRepository, entity.Site, entity.Address);
await UpsertTbReceiptAndTbReceiptDetailAsync(entity); await UpsertTbReceiptAndTbReceiptDetailAsync(entity, tenant.Id);
await CurrentUnitOfWork.SaveChangesAsync(); await CurrentUnitOfWork.SaveChangesAsync();
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -122,22 +125,19 @@ namespace Win_in.Sfs.Scp.WebApi
} }
} }
private async Task UpsertTbReceiptAndTbReceiptDetailAsync(UnplannedReceipt entity) private async Task UpsertTbReceiptAndTbReceiptDetailAsync(UnplannedReceipt entity, Guid tenantId)
{ {
//使用AutoMapper执行类型转换 //使用AutoMapper执行类型转换
var tbReceipt = ObjectMapper.Map<UnplannedReceipt, TB_RECEIVE_QAD>(entity); var tbReceipt = ObjectMapper.Map<UnplannedReceipt, TB_RECEIVE_QAD>(entity);
var tbReceiveDetail = ObjectMapper.Map<UnplannedReceipt, TB_RECEIVE_DETAIL_QAD>(entity); var tbReceiveDetail = ObjectMapper.Map<UnplannedReceipt, TB_RECEIVE_DETAIL_QAD>(entity);
tbReceipt.TenantId = tenantId;
var tenant = await _tenantStore.FindAsync(tbReceipt.Site);
using (CurrentTenant.Change(tenant.Id, tenant.Name))
{
//根据传入数据新增或修改SCP数据 //根据传入数据新增或修改SCP数据
await _tbReceiptRepository.UpsertAsync(tbReceipt); await _tbReceiptRepository.UpsertAsync(tbReceipt);
tbReceiveDetail.TenantId = tenantId;
//根据传入数据新增或修改SCP数据 //根据传入数据新增或修改SCP数据
await _tbReceiptDetailRepository.UpsertAsync(tbReceiveDetail); await _tbReceiptDetailRepository.UpsertAsync(tbReceiveDetail);
} }
} }
}
} }

23
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Validator.cs

@ -2,28 +2,41 @@
using System.Linq; using System.Linq;
using System.Linq.Dynamic.Core; using System.Linq.Dynamic.Core;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.MultiTenancy;
using Volo.Abp.TenantManagement;
using Win_in.Sfs.Scp.v1.Domain; using Win_in.Sfs.Scp.v1.Domain;
namespace Win_in.Sfs.Scp.WebApi; namespace Win_in.Sfs.Scp.WebApi;
public static class Validator public static class Validator
{ {
public const string VALID_SITES = "T8"; private static string VALID_SITES = "";
public static void CheckSite(string validSites,string site)
public static void CheckSite(ITenantRepository tenantRepository,string site)
{ {
if (!validSites.Contains(site) ) if (string.IsNullOrEmpty(VALID_SITES))
{
var tenants = tenantRepository.GetListAsync().GetAwaiter().GetResult();
VALID_SITES = tenants.Select(p => p.Name).JoinAsString(",");
}
if (!VALID_SITES.Contains(site) )
{ {
throw new UserFriendlyException($"Site must be in [{validSites}]"); throw new UserFriendlyException($"Site must be in [{VALID_SITES}]");
} }
} }
public static void CheckSupplierCode(ITaVenderRepository taVenderRepository, string site, string supplierCode) public static void CheckSupplierCode(ITaVenderRepository taVenderRepository, string site, string supplierCode)
{ {
if (!taVenderRepository.Any(p =>p.Site==site && p.VendId == supplierCode))
if (!taVenderRepository.Any(p => p.Site == site && p.VendId == supplierCode))
{ {
throw new UserFriendlyException($"Wrong supplier code: [{supplierCode}] of Site: [{site}]"); throw new UserFriendlyException($"Wrong supplier code: [{supplierCode}] of Site: [{site}]");
} }
} }
} }

2
WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Parts/TA_PART.cs

@ -42,6 +42,6 @@ namespace Win_in.Sfs.Scp.v1.Domain
public bool? Ischeck { get; set; } public bool? Ischeck { get; set; }
public Guid? TenantId { get; } public Guid? TenantId { get; set; }
} }
} }

2
WebApiService/src/Win_in.Sfs.Scp.v1.Domain/PurchaseOrders/TB_PO.cs

@ -32,6 +32,6 @@ namespace Win_in.Sfs.Scp.v1.Domain
public bool IsDeleted { get; set; } public bool IsDeleted { get; set; }
public Guid GUID { get; set; } public Guid GUID { get; set; }
public Guid? TenantId { get; } public Guid? TenantId { get; set; }
} }
} }

2
WebApiService/src/Win_in.Sfs.Scp.v1.Domain/PurchaseOrders/TB_PO_DETAIL.cs

@ -42,6 +42,6 @@ namespace Win_in.Sfs.Scp.v1.Domain
public Guid GUID { get; set; } public Guid GUID { get; set; }
public Guid? TenantId { get; } public Guid? TenantId { get; set; }
} }
} }

2
WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Receipts/TB_RECEIVE_DETAIL_QAD.cs

@ -43,6 +43,6 @@ namespace Win_in.Sfs.Scp.v1.Domain
public string Extend2 { get; set; } public string Extend2 { get; set; }
public string Extend3 { get; set; } public string Extend3 { get; set; }
public string SubSite { get; set; } public string SubSite { get; set; }
public Guid? TenantId { get; } public Guid? TenantId { get; set; }
} }
} }

2
WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Receipts/TB_RECEIVE_QAD.cs

@ -31,6 +31,6 @@ namespace Win_in.Sfs.Scp.v1.Domain
public string SubSite { get; set; } public string SubSite { get; set; }
public Guid? TenantId { get; } public Guid? TenantId { get; set; }
} }
} }

2
WebApiService/src/Win_in.Sfs.Scp.v1.Domain/Suppliers/TA_VENDER.cs

@ -47,6 +47,6 @@ namespace Win_in.Sfs.Scp.v1.Domain
public decimal? Quota { set; get; } public decimal? Quota { set; get; }
public Guid? TenantId { get; } public Guid? TenantId { get; set; }
} }
} }
Loading…
Cancel
Save