예제 #1
0
        public ActionResult UserProfile(UserProfileViewModel model)
        {
            try
            {
                if (model.CaptchaText == HttpContext.Session["captchastring"].ToString())
                {
                    ViewBag.Message = "CAPTCHA correcto!";
                }
                else
                {
                    ViewBag.Message = "CAPTCHA incorrecto!";
                    ModelState["CaptchaText"].Errors.Add("CAPTCHA incorrecto!");
                }

                if (!ModelState.IsValid)
                {
                    var errors = new Dictionary<string, object>();
                    foreach (var key in ModelState.Keys)
                    {
                        if (ModelState[key].Errors.Count > 0)
                        {
                            errors[key] = ModelState[key].Errors;
                        }
                        else
                            errors[key] = "";
                    }

                    ModelState.Clear();
                    return Json(new { success = false, errores = errors, validaciones = "", view = model });
                }

                ModelState.Clear();

                // Guardo el cambio
                ClsAgente agt = new ClsAgente();
                if (agt.UpdateAgenteWeb(Convert.ToInt32(model.AgenteID), model.ConfirmPassword, model.Email))
                {
                    var logged = (DataSet)Session["UserObj"];
                    logged.Tables["catAgentes"].Rows[0]["Email"] = model.Email;
                    logged.Tables["catAgentes"].Rows[0]["cPasww"] = model.ConfirmPassword;

                    Session["UserObj"] = logged;
                    Session["ChangePassword"] = null;
                    //*cambio aqui
                }

                return PartialView(model);
            }
            catch (Exception err)
            {
                Response.StatusCode = (int)(System.Net.HttpStatusCode.InternalServerError);
                LogDeErrores.RegistroErrorWeb(err, DatoUsuario.idAgente, DatoUsuario.nomAgente, DatoUsuario.sIp, DatoUsuario.sHostName);
                return Json("ErrInterno");
            }
        }
예제 #2
0
 public ActionResult ResetPassword(string userID)
 {
     // Envio el correo
     LoginViewModel model = new LoginViewModel();
      ClsAgente agt = new ClsAgente();
      if (agt.UpdateAgenteWeb(Convert.ToInt32(userID), "agente" + userID, ""))
      {
          ModelState.AddModelError("", "Se restablecio su contraseña correctamente");
          return Content("OK");
      }
      return Content("OK");
 }