|
|
|
@ -9,10 +9,11 @@ using System.Threading.Tasks; |
|
|
|
using Volo.Abp.Domain.Repositories; |
|
|
|
using Volo.Abp.Domain.Services; |
|
|
|
using Volo.Abp; |
|
|
|
using Volo.Abp.Domain.Entities; |
|
|
|
|
|
|
|
namespace Shentun.Peis.Poisons |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
public class PoisonManager : DomainService |
|
|
|
{ |
|
|
|
private readonly IRepository<Poison, Guid> _poisonRepository; |
|
|
|
@ -37,12 +38,17 @@ namespace Shentun.Peis.Poisons |
|
|
|
{ |
|
|
|
DataHelper.CheckEntityIsNull(entity); |
|
|
|
DataHelper.CheckStringIsNull(entity.DisplayName, "名称"); |
|
|
|
await EntityHelper.CheckSameName<Poison, Guid>(_poisonRepository, entity.DisplayName); |
|
|
|
|
|
|
|
var isPoison = await _poisonRepository.FirstOrDefaultAsync(f => f.PoisonTypeId == entity.PoisonTypeId && f.DisplayName == entity.DisplayName); |
|
|
|
if (isPoison != null) |
|
|
|
throw new UserFriendlyException($"毒害因素{entity.DisplayName}已存在"); |
|
|
|
//await EntityHelper.CheckSameName<Poison, Guid>(_poisonRepository, entity.DisplayName);
|
|
|
|
return new Poison |
|
|
|
{ |
|
|
|
DisplayName = entity.DisplayName, |
|
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(entity.DisplayName), |
|
|
|
DisplayOrder = await EntityHelper.CreateMaxDisplayOrder<Poison>(_poisonRepository) |
|
|
|
DisplayOrder = await EntityHelper.CreateMaxDisplayOrder<Poison>(_poisonRepository), |
|
|
|
PoisonTypeId = entity.PoisonTypeId |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
@ -62,13 +68,18 @@ namespace Shentun.Peis.Poisons |
|
|
|
DataHelper.CheckStringIsNull(sourceEntity.DisplayName, "名称"); |
|
|
|
if (sourceEntity.DisplayName != targetEntity.DisplayName) |
|
|
|
{ |
|
|
|
|
|
|
|
await EntityHelper.CheckSameName<Poison, Guid>(_poisonRepository, sourceEntity.DisplayName, targetEntity); |
|
|
|
var isPoison = await _poisonRepository.FirstOrDefaultAsync(f => f.PoisonTypeId == sourceEntity.PoisonTypeId |
|
|
|
&& f.DisplayName == sourceEntity.DisplayName && f.Id != targetEntity.Id); |
|
|
|
if (isPoison != null) |
|
|
|
throw new UserFriendlyException($"毒害因素{sourceEntity.DisplayName}已存在"); |
|
|
|
//await EntityHelper.CheckSameName<Poison, Guid>(_poisonRepository, sourceEntity.DisplayName, targetEntity);
|
|
|
|
targetEntity.DisplayName = sourceEntity.DisplayName; |
|
|
|
targetEntity.SimpleCode = LanguageConverter.GetPYSimpleCode(targetEntity.DisplayName); |
|
|
|
targetEntity.PoisonTypeId = sourceEntity.PoisonTypeId; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
targetEntity.PoisonTypeId = sourceEntity.PoisonTypeId; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|