public IActionResult SearchAccounts(AccountSearchRequest request) { if (this.ModelState.IsValid) { var accounts = _accountService.SearchAccounts(request); return(Ok(accounts)); } return(BadRequest(ModelState)); }
public List <Account> SearchAccounts(AccountSearchRequest request) { var allAccounts = _accountRepository.GetAccounts(); try { var searchedAccounts = allAccounts.Where(i => (!string.IsNullOrEmpty(i.Name) && i.Name.ToLower().Contains(request.AccountName.ToLower())) && (!string.IsNullOrEmpty(i.Number) && i.Number.ToLower().Contains(request.AccountNumber.ToLower()))).ToList(); return(searchedAccounts); } catch (Exception e) { throw e; } }