|
|
|
@ -78,18 +78,18 @@ namespace Myshipping.Application.Service
|
|
|
|
|
{
|
|
|
|
|
BookingSoTemplate model = null;
|
|
|
|
|
|
|
|
|
|
//同一客户,同一船公司,只允许生效一个模板。
|
|
|
|
|
if (input.Id > 0)
|
|
|
|
|
{
|
|
|
|
|
//同一用户,同一船公司,只允许生效一个模板。
|
|
|
|
|
if (input.IsEnable)
|
|
|
|
|
{
|
|
|
|
|
var c = _rep.AsQueryable().Filter(null, true).Count(x => x.IsDeleted == false && x.CustName == input.CustName && x.CarrierId == input.CarrierId && x.IsEnable);
|
|
|
|
|
var c = _rep.AsQueryable().Filter(null, true).Count(x => x.IsDeleted == false && x.UserId == input.UserId && x.CarrierId == input.CarrierId && x.IsEnable && x.Id != input.Id);
|
|
|
|
|
if (c > 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"客户:{input.CustName},船司:{input.Carrier} 已存在启用的模板");
|
|
|
|
|
throw Oops.Bah($"客户:{input.CustName},用户:{input.UserName},船司:{input.Carrier} 已存在启用的模板");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (input.Id > 0)
|
|
|
|
|
{
|
|
|
|
|
model = _rep.FirstOrDefault(x => x.Id == input.Id);
|
|
|
|
|
|
|
|
|
|
input.Adapt(model);
|
|
|
|
@ -98,9 +98,14 @@ namespace Myshipping.Application.Service
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (_rep.AsQueryable().Filter(null, true).Count(x => x.IsDeleted == false && x.CustName == input.CustName && x.CarrierId == input.CarrierId) > 0)
|
|
|
|
|
//同一用户,同一船公司,只允许生效一个模板。
|
|
|
|
|
if (input.IsEnable)
|
|
|
|
|
{
|
|
|
|
|
var c = _rep.AsQueryable().Filter(null, true).Count(x => x.IsDeleted == false && x.UserId == input.UserId && x.CarrierId == input.CarrierId && x.IsEnable);
|
|
|
|
|
if (c > 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah($"客户:{input.CustName},船司:{input.Carrier} 已创建过模板");
|
|
|
|
|
throw Oops.Bah($"客户:{input.CustName},用户:{input.UserName},船司:{input.Carrier} 已存在启用的模板");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model = input.Adapt<BookingSoTemplate>();
|
|
|
|
|