/// <summary>
        /// Checks if user with given password exists in the database
        /// </summary>
        /// <param name="_username">User name</param>
        /// <param name="_password">User password</param>
        /// <returns>True if user exist and password is correct</returns>
        public bool IsValid(string _username, string _password)
        {
            MainDataClassDataContext db = new MainDataClassDataContext();
            String _hashPassword = SHA1.Encode(_password);
            var record = from u in db.users
                         where u.email.ToString() == _username
                         && u.hash_password.ToString() == _hashPassword
                         select u;
            var user = record.SingleOrDefault();

            if (user != null)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
 public TopicController()
 {
     this.db = new MainDataClassDataContext();
 }
 public UserController()
 {
     dbContext = new DAO.MainDataClassDataContext();
 }
 public RoomsController()
 {
     this.db = new MainDataClassDataContext();
 }