예제 #1
0
 /* --------------------------------------------------------------------------------------  */
 public Boolean AgregarUsuario(RegisterModel m)
 {
     usuario U = new usuario
     {
         username = m.UserName,
         password = m.Password,
         nombre = m.Nombre,
         apellido = m.Apellido,
         fechanac = m.Fechanac,
         email = m.Email,
         idrol = m.idrol,
     };
     try
     {
         db.usuarios.InsertOnSubmit(U);
         db.SubmitChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    WebSecurity.CreateUserAndAccount(model.UserName, model.Password);
                    WebSecurity.Login(model.UserName, model.Password);
                    return RedirectToAction("Index", "Home");
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
예제 #3
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                String createStatus = this.CreateUser(model.UserName);
                if (createStatus == "Success")
                {
                    if (AgregarUsuario(model))
                    {
                        TempData["Message"] = "Se Realizo con exito su registro.";
                        return RedirectToAction("Index", "Home");
                    }
                }
                else
                {
                    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }

            // Si llegamos hasta aquí, algo falló, redisplay form
            return View(model);
        }
예제 #4
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus;
                Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */);
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }