public string Registro(string p_nombre, String p_contrasena, String p_repetir_contrasena, string p_email, string p_apellidos, string p_nick, string p_foto, string p_biografia, Nullable<DateTime> p_fecha_nacim)
        {
            /*PROTECTED REGION ID(EnMiNeveraGenNHibernate.CEN.EnMiNevera_Usuario_registro) ENABLED START*/

            // Write here your custom code...

            UsuarioCEN usuarioCEN = new UsuarioCEN ();
            String oid = null;
            String sFormato;

            sFormato = "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";
            //if (p_nombre != null && p_email != null && p_contrasena != null && p_repetir_contrasena != null && p_apellidos != null && p_nick != null && p_foto != null && p_biografia != null && p_fecha_nacim != null)

               // if ((p_contrasena.Length >= 6) && (p_contrasena.Equals (p_repetir_contrasena))) {
                      //  if (System.Text.RegularExpressions.Regex.IsMatch (p_email, sFormato)) {
                           //     if (System.Text.RegularExpressions.Regex.Replace (p_email, sFormato, String.Empty).Length == 0) {
                                        oid = usuarioCEN.New_ (p_nick, p_nombre, p_contrasena, p_email, p_apellidos, p_nick, p_foto, p_biografia, p_fecha_nacim, false, Enumerated.EnMiNevera.RolesEnum.usuario);
                            //    }
                      //  }
              /*  }
                else{
                        throw new NotImplementedException ("No se ha podido registrar el usuario.");
                }*/

            return oid;

            /*PROTECTED REGION END*/
        }
        public int Registro(string p_nombre, String p_contrasena, String p_repetir_contrasena, string p_email, string p_apellidos, string p_nick, string p_foto, string p_biografia, Nullable <DateTime> p_fecha_nacim)
        {
            /*PROTECTED REGION ID(EnMiNeveraGenNHibernate.CEN.EnMiNevera_Usuario_registro) ENABLED START*/

            // Write here your custom code...

            UsuarioCEN usuarioCEN = new UsuarioCEN();
            int        oid        = 0;
            String     sFormato;

            sFormato = "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";
            if (p_nombre != null && p_email != null && p_contrasena != null && p_repetir_contrasena != null && p_apellidos != null && p_nick != null && p_foto != null && p_biografia != null && p_fecha_nacim != null)
            {
                if ((p_contrasena.Length >= 6) && (p_contrasena.Equals(p_repetir_contrasena)))
                {
                    if (System.Text.RegularExpressions.Regex.IsMatch(p_email, sFormato))
                    {
                        if (System.Text.RegularExpressions.Regex.Replace(p_email, sFormato, String.Empty).Length == 0)
                        {
                            //oid = usuarioCEN.New_ (p_nombre, EnMiNeveraGenNHibernate.Utils.Util.GetEncondeMD5(p_contrasena), p_email, p_apellidos, p_nick, p_foto, p_biografia, p_fecha_nacim, false, Enumerated.EnMiNevera.RolesEnum.usuario);
                            // No es necesario el GetEncodeMD5 aqu�, ya que el New_ al ser Password, lo hace autom�ticamente
                            oid = usuarioCEN.New_(p_nombre, p_contrasena, p_email, p_apellidos, p_nick, p_foto, p_biografia, p_fecha_nacim, false, Enumerated.EnMiNevera.RolesEnum.usuario);
                        }
                    }
                }
                else
                {
                    throw new NotImplementedException("No se ha podido registrar el usuario.");
                }
            }

            return(oid);


            /*PROTECTED REGION END*/
        }
Example #3
0
        public ActionResult Register(RegisterModel model, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                // Intento de registrar al usuario
                string imagesDir = "Images/Uploads";

                string fileName = "", path = "";

                if (file != null && file.ContentLength > 0)
                {
                    // extract only the fielname
                    fileName = System.IO.Path.GetFileName(file.FileName);
                    // store the file inside ~/App_Data/uploads folder
                    path = Path.Combine(Server.MapPath("~/"+imagesDir), fileName);
                    //string pathDef = path.Replace(@"\\", @"\");
                    file.SaveAs(path);
                }

                try
                {
                    fileName = "/" + imagesDir + "/" + fileName;
                    model.Foto = fileName;
                    // Invocamos a la lógica de negocio para crear un cliente.
                    UsuarioCEN cen = new UsuarioCEN();
                    cen.New_(model.Nombre, model.Contrasena, model.Email, model.Apellidos, model.Nick, model.Foto, model.Biografia, model.FechaNacim, false, RolesEnum.usuario);

                    WebSecurity.CreateUserAndAccount(model.Nick, model.Contrasena);
                    WebSecurity.Login(model.Nick, model.Contrasena);
                    return RedirectToAction("Index", "Home");
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // Si llegamos a este punto, es que se ha producido un error y volvemos a mostrar el formulario
            return View(model);
        }