protected void CreateUser_Click(object sender, EventArgs e) { string userName = UserName.Text; var manager = new AuthenticationIdentityManager(new IdentityStore()); User u = new User(userName) { UserName = userName }; IdentityResult result = manager.Users.CreateLocalUser(u, Password.Text); if (result.Success) { manager.Authentication.SignIn(Context.GetOwinContext().Authentication, u.Id, isPersistent: false); //OpenAuthProviders.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response); using (SocialNetworkDbEntities context = new SocialNetworkDbEntities()) { UserDetail details = new UserDetail(); context.UserDetails.Add(details); context.SaveChanges(); var user = context.AspNetUsers.Find(u.Id); user.UserDetailsId = details.UserDetailsId; context.SaveChanges(); } Response.Redirect("~/Account/UserDetails"); } else { ErrorMessage.Text = result.Errors.FirstOrDefault(); } }
public static void AddUsers() { var context = new SocialNetworkContext(); if (context.Users.Any()) { return; } var straho = new User() { Name = "Strahil", Username = "******" }; var plamena = new User() { Name = "Plamena", Username = "******" }; context.Users.Add(straho); context.Users.Add(plamena); context.SaveChanges(); }
public ActionResult PersonalOffice(User user) { return View(user); }
public ActionResult EditUser(User user) { return View(); }
public ActionResult EditUser(User user) { db.Users.Find(id).FirstName = user.FirstName; db.Users.Find(id).LastName = user.LastName; db.Users.Find(id).Sex = user.Sex; db.Users.Find(id).Family_status = user.Family_status; db.Users.Find(id).Day = user.Day; db.Users.Find(id).Month = user.Month; db.Users.Find(id).Year = user.Year; db.Users.Find(id).Birthplace = user.Birthplace; db.Users.Find(id).Сountry = user.Сountry; db.Users.Find(id).City = user.City; db.Users.Find(id).Phone = user.Phone; db.Users.Find(id).Skype = user.Skype; db.Users.Find(id).Personal_site = user.Personal_site; db.Users.Find(id).Working = user.Working; db.Users.Find(id).Hobbies = user.Hobbies; db.Users.Find(id).Music = user.Music; db.Users.Find(id).Films = user.Films; db.Users.Find(id).Books = user.Books; db.Users.Find(id).About_myself = user.About_myself; db.Users.Find(id).Status = user.Status; db.SaveChanges(); return View(user); }
public ActionResult PersonalOffice(User user) { user = db.Users.Find(id); return View(user); }
public void AddUser(string username, string email, bool isEnglish) { int idx = id++; User u = new User(username, email, id, isEnglish); users.Add(idx, u); }
private User GetUserFromNode(XmlNode username, XmlNode firstName, XmlNode lastName, XmlNode registeredOn) { var user = new User() { UserName = username.InnerText, FirstName = firstName == null ? null : firstName.InnerText, LastName = lastName == null ? null : lastName.InnerText, RegistrationDate = DateTime.Parse(registeredOn.InnerText) }; return user; }