protected override async Task CheckNewItemIsUnique(Position value) { // is there already a Position with the same id? if (await Repository.Query().AnyAsync(e => e.Id == value.Id)) { throw ConflictException.IdConflict(nameof(Position), value.Id); } // does the Tenant already have a Position of the same name? if (await Repository.Query().AnyAsync(e => e.Name == value.Name && e.TenantId == value.TenantId )) { throw BadRequestException.NamedEntityExists(nameof(Department), value.Name); } }
protected override async Task CheckNewItemIsUnique(BranchOffice value) { // does the Tenant already have a BranchOffice of the same name? if (await Repository.Query().AnyAsync(e => e.Id == value.Id)) { throw ConflictException.IdConflict(nameof(BranchOffice), value.Id); } // does the Tenant already have a BranchOffice of the same name? if (await Repository.Query().AnyAsync( e => e.Name == value.Name && e.TenantId == value.TenantId )) { throw BadRequestException.NamedEntityExists(nameof(BranchOffice), value.Name); } }
protected override async Task CheckNewItemIsUnique(Employee value) { // is there already an Employee entity with the same id? if (await Repository.Query().AnyAsync(e => e.Id == value.Id)) { throw ConflictException.IdConflict(nameof(Employee), value.Id); } // does the Department already have an Employee of the same name? if (await Repository.Query().AnyAsync(e => e.FirstName == value.FirstName && e.LastName == value.LastName && e.Patronymic == value.Patronymic && e.BranchOfficeId == value.BranchOfficeId && e.DepartmentId == value.DepartmentId && e.ExternalId == value.ExternalId && e.TenantId == value.TenantId)) { throw BadRequestException.NamedEntityExists(nameof(Employee), value.FullName); } }