public bool ActivateUser(string username, string key) { using (RssFeedDBConnection db = new RssFeedDBConnection()) { var result = from u in db.Users where (u.UserName == username) select u; if (result.Count() != 0) { var dbuser = result.First(); if (dbuser.NewEmailKey == key) { dbuser.IsActivated = true; dbuser.LastModifiedDate = DateTime.Now; dbuser.NewEmailKey = null; db.SaveChanges(); return true; } else { return false; } } else { return false; } } }
public static User GetUserByID(Guid ID) { RssFeedDBConnection db = new RssFeedDBConnection(); User user = new User(); user = db.Users.SingleOrDefault(u => u.ID == ID); return user; }
public static Guid GetIDByName(string Name) { RssFeedDBConnection db = new RssFeedDBConnection(); Guid ID; User user = db.Users.SingleOrDefault(u => u.UserName == Name); ID = user.ID; return ID; }
public MembershipUser GetUser(string username) { using (RssFeedDBConnection db = new RssFeedDBConnection()) { var result = from u in db.Users where (u.UserName == username) select u; if (result.Count() != 0) { var dbuser = result.FirstOrDefault(); string _username = dbuser.UserName; Guid _providerUserKey = dbuser.ID; string _email = dbuser.Email; string _passwordQuestion = ""; string _comment = dbuser.Comments; bool _isApproved = dbuser.IsActivated; bool _isLockedOut = dbuser.IsLockedOut; DateTime _creationDate = dbuser.CreatedDate; DateTime _lastLoginDate = dbuser.LastLoginDate; DateTime _lastActivityDate = DateTime.Now; DateTime _lastPasswordChangedDate = DateTime.Now; DateTime _lastLockedOutDate = dbuser.LastLockedOutDate; MembershipUser user = new MembershipUser("CustomMembershipProvider", _username, _providerUserKey, _email, _passwordQuestion, _comment, _isApproved, _isLockedOut, _creationDate, _lastLoginDate, _lastActivityDate, _lastPasswordChangedDate, _lastLockedOutDate); return user; } else { return null; } } }
public MembershipUser CreateUser(string username, string password, string email) { using (RssFeedDBConnection db = new RssFeedDBConnection()) { User user = new User(); user.ID = Guid.NewGuid(); user.UserName = username; user.Email = email; user.PasswordSolt = CreateSalt(); user.Password = CreatePasswordHash(password, user.PasswordSolt); user.CreatedDate = DateTime.Now; user.IsActivated = false; user.IsLockedOut = false; user.LastLockedOutDate = DateTime.Now; user.LastLoginDate = DateTime.Now; user.NewEmailKey = GenerateKey(); db.AddToUsers(user); db.SaveChanges(); SendEmailKey(user); return GetUser(username); } }
public bool ValidateUser(string username, string password) { using (RssFeedDBConnection db = new RssFeedDBConnection()) { var result = from u in db.Users where (u.UserName == username) select u; if (result.Count() != 0) { var dbuser = result.First(); if (dbuser.Password == CreatePasswordHash(password, dbuser.PasswordSolt) && dbuser.IsActivated == true) return true; else return false; } else { return false; } } }
public string GetUserNameByEmail(string email) { using (RssFeedDBConnection db = new RssFeedDBConnection()) { var result = from u in db.Users where (u.Email == email) select u; if (result.Count() != 0) { var dbuser = result.FirstOrDefault(); return dbuser.UserName; } else { return ""; } } }
public static User GetUserByName(string Name) { RssFeedDBConnection db = new RssFeedDBConnection(); User user = db.Users.SingleOrDefault(u => u.UserName == Name); return user; }