Browse Source

验证重复

groupmealmanage
zhaoy 9 months ago
parent
commit
e59fdcbb2d
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      BPA.SAAS.Manage.Application/DataBase/Services/GoodsEnergyConfigService.cs

+ 2
- 2
BPA.SAAS.Manage.Application/DataBase/Services/GoodsEnergyConfigService.cs View File

@@ -61,7 +61,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
try
{
_db.Ado.BeginTran();
var resEntity = _db.Queryable<BPA_GoodsEnergyConfig>().First(it => it.Name == dto.Name);
var resEntity = _db.Queryable<BPA_GoodsEnergyConfig>().First(it => it.Name == dto.Name && it.GoodsId != dto.GoodsId);
if (resEntity != null) throw Oops.Oh("配置名称已存在");
var newType = new BPA_GoodsEnergyConfig
{
@@ -105,7 +105,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
// 查询数据库中是否存在未删除的商品类型
var resEntity = _db.Queryable<BPA_GoodsEnergyConfig>().First(it => it.Id == dto.Id);
if (null == resEntity) throw Oops.Oh("配置不存在");
var resEntity1 = _db.Queryable<BPA_GoodsEnergyConfig>().First(it => it.Name == dto.Name && it.Id != dto.Id);
var resEntity1 = _db.Queryable<BPA_GoodsEnergyConfig>().First(it => it.Name == dto.Name && it.Id != dto.Id && it.GoodsId!= dto.GoodsId);
if (resEntity1 != null) throw Oops.Oh("配置名称已存在");
resEntity.Name = dto.Name;
resEntity.Uint = dto.Uint;


Loading…
Cancel
Save