public async Task <IPersonalData> FindClientAsync(string phrase) { if (string.IsNullOrEmpty(phrase)) { return(null); } if (phrase.IsGuid()) { return(await _personalDataRepository.GetAsync(phrase)); } if (phrase.IsValidEmail()) { var client = await _clientAccountsRepository.GetByEmailAsync(phrase); if (client == null) { return(null); } return(await _personalDataRepository.GetAsync(client.Id)); } return(await _personalDataRepository.ScanAndFindAsync(itm => (!string.IsNullOrEmpty(itm.FirstName) && itm.FirstName.ToLower().Contains(phrase)) || (!string.IsNullOrEmpty(itm.LastName) && itm.LastName.ToLower().Contains(phrase)) || (!string.IsNullOrEmpty(itm.Email) && itm.Email.ToLower().Contains(phrase)) )); }
public async Task <IPersonalData> FindClientAsync(string phrase) { if (string.IsNullOrEmpty(phrase)) { return(null); } if (phrase.IsGuid()) { return(await _personalDataRepository.GetAsync(phrase)); } if (phrase.IsValidEmail()) { var client = await _clientAccountsRepository.GetByEmailAsync(phrase); if (client == null) { return(null); } return(await _personalDataRepository.GetAsync(client.Id)); } var phoneNum = phrase.GetDigitsAndSymbols(); var result = await _personalDataRepository.ScanAndFindAsync(itm => (!string.IsNullOrEmpty(itm.FullName) && itm.FullName.ToLower().Contains(phrase)) || (!string.IsNullOrEmpty(itm.Email) && itm.Email.ToLower().Contains(phrase)) || (!string.IsNullOrEmpty(itm.ContactPhone) && !string.IsNullOrEmpty(phoneNum) && itm.ContactPhone.Contains(phoneNum)) ); if (result != null) { return(result); } result = await FindByWalletAsync(phrase); return(result); }