Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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;

            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUsers(User user)
 {
     base.AddObject("Users", user);
 }
Ejemplo n.º 4
0
 /// <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;
 }
Ejemplo n.º 5
0
        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;
        }
Ejemplo n.º 6
0
        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;

            }
        }