/// <summary> /// Deprecated Method for adding a new object to the User_Profile EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToUser_Profile(User_Profile user_Profile) { base.AddObject("User_Profile", user_Profile); }
/// <summary> /// Create a new User_Profile object. /// </summary> /// <param name="userID">Initial value of the UserID property.</param> public static User_Profile CreateUser_Profile(global::System.Int64 userID) { User_Profile user_Profile = new User_Profile(); user_Profile.UserID = userID; return user_Profile; }
public ActionResult RegisterAdmin(RegisterModel model) { MembershipCreateStatus createStatus; Membership.CreateUser(model.UserName, model.Password, model.UserName, null, null, true, null, out createStatus); Guid g = new Guid("2a91441d-b054-4c88-a353-bf0d8d10af9e"); aspnet_Roles SelectedRole = db.aspnet_Roles.Single(r => r.RoleId == g); if (createStatus == MembershipCreateStatus.Success) { Roles.AddUserToRole(model.UserName, SelectedRole.RoleName); aspnet_Membership obMem = db.aspnet_Membership.SingleOrDefault(am => am.Email == model.UserName); User_Profile objUser = new User_Profile(); objUser.aspnet_userid = obMem.UserId; db.User_Profile.AddObject(objUser); db.SaveChanges(); } return RedirectToAction("UsersList"); }
public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { // Attempt to register the user try { MembershipCreateStatus createStatus; Membership.CreateUser(model.UserName, model.Password, model.UserName, null, null, true, null, out createStatus); Guid g = new Guid("79c22160-cd24-46ac-8f33-5fa8880f5512"); aspnet_Roles SelectedRole = db.aspnet_Roles.Single(r => r.RoleId == g); if (createStatus == MembershipCreateStatus.Success) { Roles.AddUserToRole(model.UserName, SelectedRole.RoleName); aspnet_Membership obMem = db.aspnet_Membership.SingleOrDefault(am => am.Email == model.UserName); User_Profile objUser = new User_Profile(); objUser.aspnet_userid = obMem.UserId; db.User_Profile.AddObject(objUser); db.SaveChanges(); FormsAuthentication.SetAuthCookie(model.UserName, false); } return RedirectToAction("Index", "Home"); } catch (MembershipCreateUserException e) { ModelState.AddModelError("", ErrorCodeToString(e.StatusCode)); } } // If we got this far, something failed, redisplay form return View(model); }
public ActionResult ProfileView(User_Profile profileModel) { if (ModelState.IsValid) { db.User_Profile.Attach(profileModel); db.ObjectStateManager.ChangeObjectState(profileModel, System.Data.EntityState.Modified); db.SaveChanges(); return RedirectToAction("Index","Home"); } return View(profileModel); }