|
|
@ -4,7 +4,6 @@ using System.Collections.Generic; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
using System.Text; |
|
|
using System.Text; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
using Volo.Abp.Auditing; |
|
|
|
|
|
using Volo.Abp; |
|
|
using Volo.Abp; |
|
|
using Volo.Abp.Domain.Entities; |
|
|
using Volo.Abp.Domain.Entities; |
|
|
using Volo.Abp.Domain.Repositories; |
|
|
using Volo.Abp.Domain.Repositories; |
|
|
@ -125,21 +124,21 @@ namespace Shentun.Peis |
|
|
/// <param name="updatedEntity"></param>
|
|
|
/// <param name="updatedEntity"></param>
|
|
|
/// <returns></returns>
|
|
|
/// <returns></returns>
|
|
|
/// <exception cref="UserFriendlyException"></exception>
|
|
|
/// <exception cref="UserFriendlyException"></exception>
|
|
|
public static async Task CheckSameName<TEntity,TKey>(IRepository<TEntity> repository,string name, TEntity updatedEntity = null) |
|
|
|
|
|
|
|
|
public static async Task CheckSameName<TEntity, TKey>(IRepository<TEntity, TKey> repository, string name, TEntity updatedEntity = null) |
|
|
where TEntity : class, IEntity<TKey>, IDisplayName |
|
|
where TEntity : class, IEntity<TKey>, IDisplayName |
|
|
{ |
|
|
{ |
|
|
Check.NotNullOrWhiteSpace(name, nameof(name)); |
|
|
Check.NotNullOrWhiteSpace(name, nameof(name)); |
|
|
TEntity existEntity; |
|
|
TEntity existEntity; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (updatedEntity == null) |
|
|
if (updatedEntity == null) |
|
|
{ |
|
|
{ |
|
|
existEntity = await repository.FindAsync(o => o.DisplayName == name); |
|
|
existEntity = await repository.FindAsync(o => o.DisplayName == name); |
|
|
} |
|
|
} |
|
|
else |
|
|
|
|
|
|
|
|
else |
|
|
{ |
|
|
{ |
|
|
existEntity = await repository.FindAsync(o => o.Id.ToString() != updatedEntity.Id.ToString() && o.DisplayName == name); |
|
|
existEntity = await repository.FindAsync(o => o.Id.ToString() != updatedEntity.Id.ToString() && o.DisplayName == name); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (existEntity != null) |
|
|
if (existEntity != null) |
|
|
{ |
|
|
{ |
|
|
|