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) { DataClasses1DataContext db = new DataClasses1DataContext(); System.Guid idus = db.aspnet_Users.Where(a => a.UserName == model.UserName).Select(a=>a.UserId).ToArray()[0]; System.Guid idrol = db.aspnet_Roles.Where(a=>a.RoleName == "usuario").Select(a=>a.RoleId).ToArray()[0]; aspnet_UsersInRole r1 = new aspnet_UsersInRole(); r1.UserId = idus; r1.RoleId = idrol; db.aspnet_UsersInRoles.InsertOnSubmit(r1); PERSONA n = new PERSONA(); int idPersona = Convert.ToInt32(db.PERSONAs.Max(a => a.ID_PERSONA).ToString()); n.ID_PERSONA = idPersona+1; n.UserId = idus; n.NOMBRE = model.Nombre; n.APATERNO = model.app; n.AMATERNO = model.apm; n.DESCRIPCION = model.descripcion; n.UBICACION = model.ubicacion; db.PERSONAs.InsertOnSubmit(n); db.SubmitChanges(); FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */); return RedirectToAction("Perfil", "Usuario"); } else { ModelState.AddModelError("", ErrorCodeToString(createStatus)); } } // If we got this far, something failed, redisplay form return View(model); }
partial void UpdatePERSONA(PERSONA instance);
partial void DeletePERSONA(PERSONA instance);
partial void InsertPERSONA(PERSONA instance);