public static async Task ValidateUniqueEmail(IReadOnlyRepository readOnlyRepository, AddExampleModel request) { var query = readOnlyRepository.Query <Example>(x => x.Status == EnabledStatus.Enabled && x.Email == request.Email); var exists = await readOnlyRepository.AnyAsync(query); if (exists) { throw new ObjectValidationException(nameof(request.Email), $"Email {request.Email} is already assigned to an example."); } }
private async Task <bool> LabelDoesNotExist(string name, CancellationToken cancellationToken) { return(await _labelReadOnlyRepository.AnyAsync(new LabelFilterSpecifications.ByName(name)) .ConfigureAwait(false)); }
private async Task <bool> AuthorExist(Guid authorUid, CancellationToken cancellationToken) { return(await _userReadOnlyRepository.AnyAsync(new UserFilterSpecificationses.ByUid(authorUid)) .ConfigureAwait(false)); }
private async Task <bool> UserNotExist(string nickname, CancellationToken cancellationToken) { return(await _userReadOnlyRepository.AnyAsync(new UserFilterSpecificationses.ByNickname(nickname)) .ConfigureAwait(false)); }