public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { // Intento de registrar al usuario try { TareasEntities db = new TareasEntities(); ViewBag.InstitucionList = new SelectList(db.Instituciones, "id", "razonSocial", model.idInstitucion); WebSecurity.CreateUserAndAccount(model.UserName, model.Password, new { email = model.email, idInstitucion = model.idInstitucion, estadoUsuario = 0, fechaRegistro = DateTime.Now }, false); //WebSecurity.Login(model.nombreUsuario, model.password); 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); }
public ActionResult Register() { TareasEntities db = new TareasEntities(); ViewBag.InstitucionList = new SelectList(db.Instituciones, "id", "razonSocial"); return View(); }