public ActionResult Register(User user) { try { if (ModelState.IsValid) { UserDTO regUser = _mapper.Map <UserDTO>(user); UserService.Register(regUser); Login login = new Login() { Email = regUser.Email, Password = regUser.Password }; return(Login(login)); } return(View()); } catch (FaultException <WebUIClient.UserServiceReference.ValidationFault> ex) { // Extract the Detail node from the Fault Exception. // This details is the // ValidationFault class WebUIClient.UserServiceReference.ValidationFault fault = ex.Detail; string alert = ""; foreach (WebUIClient.UserServiceReference.ValidationDetail validationResult in fault.Details) { alert = String.Concat(string.Format("Message={0} Key={1} Tag={2}", validationResult.Message, validationResult.Key, validationResult.Tag)); } return(JavaScript("<script>alert(\"" + alert + "\")</script>")); } }
public ActionResult Login(Login loginViewModel) { try { if (ModelState.IsValid) { bool Authenticated = UserService.Authenticate(loginViewModel.Password, loginViewModel.Email); if (Authenticated) { _auth.DoAuth(loginViewModel.Email, true); return(RedirectToAction("Search", "Criminals")); } } return(View(loginViewModel)); } catch (FaultException <WebUIClient.UserServiceReference.ValidationFault> ex) { // Extract the Detail node from the Fault Exception. // This details is the // ValidationFault class WebUIClient.UserServiceReference.ValidationFault fault = ex.Detail; string alert = ""; foreach (WebUIClient.UserServiceReference.ValidationDetail validationResult in fault.Details) { alert = String.Concat(string.Format("Message={0} Key={1} Tag={2}", validationResult.Message, validationResult.Key, validationResult.Tag)); } return(JavaScript("<script>alert(\"" + alert + "\")</script>")); } }