public ActionResult ActualResetPassword(DataModel model) { using (var e = new EntityContext()) { var data = ActionData.GetAction <DataModel>(Guid.Parse(model.Guid), e); model.Email = data.Item1.Email; var actionRow = data.Item2; if (model == null || actionRow == null || actionRow.Investigator_Name == null) { return(View(ResetPasswordErrorView)); } // clears the errors from the model model.ClearToaster(); // check for simple warnings var isValid = true; // makes sure we don't have any empty fields if (String.IsNullOrEmpty(model.Password) || String.IsNullOrEmpty(model.Email)) { model.AddError(GlobalErrors.EmptyFields); isValid = false; } if (!CredentialsHelper.IsPasswordValid(model.Password)) // check password is valid { model.AddError(RegistrationErrors.InvalidPassword); isValid = false; } else // if password is valid get warnings { model.AddWarnings(CredentialsHelper.GetPasswordWarnings(model.Password)); } if (isValid) // check for more serious warnings { using (var e2 = new EntityContext()) // db context { if (isValid && !model.HasWarnings()) // we have checked everything we need to check { var success = Authorize.ResetPassword(model.Email, model.Password, e2); e.Web_Action_Data.Remove(actionRow); e.SaveChanges(); if (!success) { return(View(ResetPasswordErrorView)); } else { return(View(ResetPasswordSuccessView)); } } } } } // if we got here there was an error return(View(ReceivedView, model)); }