public override bool ValidateUser(string username, string password) { if(string.IsNullOrEmpty(password.Trim())) return false; string hash = EncryptPassword(password); MvcForumsEntities forumEntities = new MvcForumsEntities(); User user = forumEntities.User.Single(dbUser => dbUser.UserName == username); if (user == null) return false; if (user.Password == password) { User = user; return true; } return false; }
public User CreateUser(string userName ,string password, string email) { using (MvcForumsEntities forumEntities = new MvcForumsEntities()) { //Checking if a user with the given name exists..if not create, otherwise return null if(forumEntities.User.Where(user => user.UserName == userName).Count() == 0) { User newUser = new User(){UserName = userName, Password = password, EmailAddress=email, CreateDate=DateTime.Now}; forumEntities.AddToUser(newUser); try { forumEntities.SaveChanges(); } catch (Exception e) { return null; } return newUser; } else return null; } }
/// <summary> /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToUsers(User user) { base.AddObject("Users", user); }
/// <summary> /// Create a new User object. /// </summary> /// <param name="userID">Initial value of the UserID property.</param> /// <param name="userName">Initial value of the UserName property.</param> /// <param name="password">Initial value of the Password property.</param> /// <param name="emailAddress">Initial value of the EmailAddress property.</param> /// <param name="createDate">Initial value of the CreateDate property.</param> public static User CreateUser(global::System.Int32 userID, global::System.String userName, global::System.String password, global::System.String emailAddress, global::System.DateTime createDate) { User user = new User(); user.UserID = userID; user.UserName = userName; user.Password = password; user.EmailAddress = emailAddress; user.CreateDate = createDate; return user; }
public override bool ValidateUser(string username, string password) { if(string.IsNullOrEmpty(password.Trim())) return false; string hash = EncryptPassword(password); MvcForumsEntities forumEntities = new MvcForumsEntities(); User user = (User)from users in forumEntities.Users where Name == username select users; if (user == null) return false; if (user.Password == password) { User = user; return true; } return false; }
public User CreateUser(string userName ,string password, string email) { using (MvcForumsEntities forumEntities = new MvcForumsEntities()) { //Checking if a user with the given name exists..if not create, otherwise return null if(forumEntities.Users.Where(user => user.UserName == userName).Count() == 0) { User newUser = new User(){UserName = userName, Password = password}; forumEntities.AddToUsers(newUser); return newUser; } else return null; } }