public async Task <IActionResult> Register(User user) { using (var context = new BPContext()) { if (!ModelState.IsValid) { return(View()); } else if (context.Users.Any(g => g.Username == user.Username)) { ModelState.AddModelError("", "Username already exists"); return(View()); } else { await UserAuthentication.AddAsync(user, context); return(View("Login")); } } }