Exemplo n.º 1
0
        public ActionResult Crear([Bind(Include = "id,user_name,user_email,user_email2,user_pass,document_type_id,doc_nro,nationality_id,contact_name,phone,address,user_role_id,user_status_id,institution_ids,address_country_id,department_id,address_municipality_id")] UserViewModel pUserViewModel)
        {
            // TODO: Add insert logic here

            if (pUserViewModel == null)
            {
                return(HttpNotFound());
            }
            pUserViewModel.id = 0;

            pUserViewModel.user_id_created = AuthorizeUserAttribute.UsuarioLogeado().user_id;

            pUserViewModel.user_pass = Helper.Encripta(Guid.NewGuid().ToString());
            string user_code = Guid.NewGuid().ToString();

            pUserViewModel.user_code_recover = user_code;
            UserBL oUserBL = new UserBL();

            oUserBL.Agregar(pUserViewModel);

            SendEmailNotificationBL oSendEmailNotificationBL = new SendEmailNotificationBL();



            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 = pUserViewModel.contact_name;
            oNotification.to   = pUserViewModel.user_email;
            oSendEmailNotificationBL.EnviarNotificacionNuevaCuenta(oNotification);

            return(RedirectToAction("Index"));
        }