public IActionResult Register(RegisterForm registerForm) { bool screenName = _userRepository.GetAll().Where(u => u.ScreenName == registerForm.ScreenName).FirstOrDefault() is null; bool email = _userRepository.GetAll().Where(u => u.Email == registerForm.Email).FirstOrDefault() is null; if (!(registerForm is null) && ModelState.IsValid) { registerForm.Passwd = Convert.ToBase64String(_cryptoService.Crypter(registerForm.Passwd)); try { if (screenName && email) { _authRepository.Register(registerForm); return(RedirectToAction("Login")); } else if (!screenName) { ViewBag.Message = "Screen Name already exists"; } else { ViewBag.Message = "Email already used"; } } catch (Exception ex) { return(View("Error")); } } return(View(registerForm.ToWeb())); }