Beispiel #1
0
        public JsonResult Recuperar([Bind(Include = "user_email")] LoginViewModel pLoginModel)
        {
            UserBL                  oUserBL                  = new UserBL();
            UserViewModel           oUserViewModel           = oUserBL.ObtenerUser(pLoginModel.user_email);
            SendEmailNotificationBL oSendEmailNotificationBL = new SendEmailNotificationBL();

            if (oUserViewModel == null || oUserViewModel.id <= 0)
            {
                return(Json(new
                {
                    message_error = "No hay una cuenta asociada al correo electrónico ingresado.",
                    status = "0",
                }));
            }
            if (oUserViewModel.user_status_id == 2)
            {
                return(Json(new
                {
                    message_error = "El usuario esta en inactivo. Por favor comuniquese con el administrador del sistema para activar su cuenta",
                    status = "0",
                }));
            }
            string user_code = Guid.NewGuid().ToString();

            oUserBL.ActualizarCodigoRecuperar(oUserViewModel.id, user_code);
            NotificationGeneralAccountViewModel oNotification = new NotificationGeneralAccountViewModel();

            oNotification.url_recuperar_cuenta = ConfigurationManager.AppSettings["site.url"] + "/Account/CambiarPassword/?code=" + user_code;
            oNotification.url_home             = ConfigurationManager.AppSettings["site.url"];
            oNotification.url_politicas        = ConfigurationManager.AppSettings["site.url.politicas"];
            oNotification.url_contacto         = ConfigurationManager.AppSettings["site.url.contacto"];
            oNotification.url_privacidad       = ConfigurationManager.AppSettings["site.url.privacidad"];
            oNotification.name = oUserViewModel.contact_name;
            oNotification.to   = oUserViewModel.user_email;
            oSendEmailNotificationBL.EnviarNotificacionRecuperarCuenta(oNotification);
            return(Json(new
            {
                // this is what datatables wants sending back
                status = "1",
            }));
        }