Beispiel #1
0
 partial void Deleteaspnet_UsersInRole(aspnet_UsersInRole instance);
Beispiel #2
0
 partial void Updateaspnet_UsersInRole(aspnet_UsersInRole instance);
Beispiel #3
0
 partial void Insertaspnet_UsersInRole(aspnet_UsersInRole instance);
Beispiel #4
0
		private void detach_aspnet_UsersInRoles(aspnet_UsersInRole entity)
		{
			this.SendPropertyChanging();
			entity.aspnet_User = null;
		}
Beispiel #5
0
		private void attach_aspnet_UsersInRoles(aspnet_UsersInRole entity)
		{
			this.SendPropertyChanging();
			entity.aspnet_Role = this;
		}
Beispiel #6
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)
                {
                    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 rel = new aspnet_UsersInRole() { RoleId = IdRol, UserId = IdUs };
                    db.aspnet_UsersInRoles.InsertOnSubmit(rel);

                    string email = db.aspnet_Memberships.Where(a => a.UserId == IdUs).Select(a => a.Email).ToArray()[0];
                    string pwd = db.aspnet_Memberships.Where(a => a.UserId == IdUs).Select(a => a.Password).ToArray()[0];
                    string nick = db.aspnet_Users.Where(a => a.UserId == IdUs).Select(a => a.UserName).ToArray()[0];
                    Usuario NuevoUsuario = new Usuario()
                    {
                        UserId = IdUs,
                        //Nick = nick,
                        //Password = pwd,
                        //Email = email,
                        Karma = 0
                    };
                    db.Usuarios.InsertOnSubmit(NuevoUsuario);
                    db.SubmitChanges();

                    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);
        }