public ZTree(Webpages_UserProfile user) { ID = user.UserId.ToString(); Name = user.UserName; NodeType = "User"; ICON = "Content/zTreeStyle/img/user.gif"; }
public ActionResult ExternalLoginConfirmation(RegisterExternalLoginModel model, string returnUrl) { string provider = null; string providerUserId = null; if (User.Identity.IsAuthenticated || !OAuthWebSecurity.TryDeserializeProviderUserId(model.ExternalLoginData, out provider, out providerUserId)) { return RedirectToAction("Manage"); } if (ModelState.IsValid) { // Insert a new user into the database using (WebPagesContext db = new WebPagesContext()) { Webpages_UserProfile user = db.UserProfiles.FirstOrDefault(u => u.UserName.ToLower() == model.UserName.ToLower()); // Check if user already exists if (user == null) { // Insert name into the profile table var newUser = new Webpages_UserProfile { UserName = model.UserName }; db.UserProfiles.Add(newUser); db.SaveChanges(); OAuthWebSecurity.CreateOrUpdateAccount(provider, providerUserId, model.UserName); OAuthWebSecurity.Login(provider, providerUserId, createPersistentCookie: false); WebSecurity.CreateAccount(model.UserName, null); return RedirectToLocal(returnUrl); } else { ModelState.AddModelError("UserName", "User name already exists. Please enter a different user name."); } } } ViewBag.ProviderDisplayName = OAuthWebSecurity.GetOAuthClientData(provider).DisplayName; ViewBag.ReturnUrl = returnUrl; return View(model); }
public override string CreateUserAndAccount(string userName, string password, bool requireConfirmation, IDictionary<string, object> values) { using (TransactionScope ts = new TransactionScope()) { if ((from u in userProfiles where u.UserName == userName select u).FirstOrDefault() != null) throw new MembershipCreateUserException(MembershipCreateStatus.DuplicateUserName); Webpages_UserProfile user = new Webpages_UserProfile() { UserName = userName }; user.Email = Convert.ToString(values["email"]); userProfiles.Add(user); dbContext.SaveChanges(); var rsl = CreateAccount(userName, password, requireConfirmation); ts.Complete(); return rsl; } }
public ActionResult EditUser(Webpages_UserProfile user) { if (ModelState.IsValid) { if (db.UserProfiles.Where(o => o.UserName == user.UserName && o.UserId != user.UserId).Any()) { return Content("User Exist"); } db.Entry(user).State = System.Data.EntityState.Modified; db.SaveChanges(); } return Content(Boolean.TrueString); }
public ActionResult CreateUser(Webpages_UserProfile user, string roleCode) { using (TransactionScope ts = new TransactionScope()) { if (db.UserProfiles.Where(o => o.UserName == user.UserName).Any()) { return Content("User Exist"); } db.UserProfiles.Add(user); db.SaveChanges(); Webpages_UsersInRoles userRole = new Webpages_UsersInRoles() { RoleCode = roleCode, UserId = user.UserId }; db.WebPagesUsersInRoles.Add(userRole); db.SaveChanges(); ts.Complete(); return Content(Boolean.TrueString); } }
public ActionResult CreateUser(string code) { ViewBag.RoleCode = code; Webpages_UserProfile user=new Webpages_UserProfile() { IndexOrder = 1 }; return View(user); }