public async Task Find()

in src/PartsUnlimitedWebsite/Areas/Admin/Controllers/CustomerController.cs [38:67]


        public async Task<IActionResult> Find(string username, string email, string phoneNumber)
        {
            IQueryable<ApplicationUser> query = _context.Users;

            if (!string.IsNullOrWhiteSpace(username))
            {
                query = query.Where(u => u.UserName == username);
            }

            if (!string.IsNullOrWhiteSpace(email))
            {
                query = query.Where(u => u.Email == email);
            }

            if (!string.IsNullOrWhiteSpace(phoneNumber))
            {
                query = query.Where(u => u.PhoneNumber == phoneNumber);
            }

            // We only want cases where there is one instance.  SingleOrDefault will throw an exception
            // when there is more than one, so we take two and only use the result if it was the only one
            var result = await query.Take(2).ToListAsync();

            if (result.Count == 1)
            {
                return RedirectToAction(nameof(Index), new { id = result[0].Id });
            }

            return View();
        }