public async Task <IActionResult> SignUp([Bind("ID,FirstName,LastName,Email,Password,ConfirmPassword,PermissionLevel,BooksHeld")] User user) { //checking if email already exists in the database var queryableUsers = _context.Users.Where(u => u.Email == user.Email); var _user = await queryableUsers.SingleOrDefaultAsync(); if (ModelState.IsValid && _user == null) { //SendEmail(user.Email, "Your Library Account", "Congratulations!\n Your account has been Successfully created!"); //success, hence, show the user that he succesfully created an account TempData["Success"] = "Congratulations, you've successfully created an account, feel free to sign in"; _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction("Index", "Home")); } else { TempData["Failure"] = "Sorry, the email is already taken"; return(RedirectToAction("Index", "Home")); } }