Exemplo n.º 1
0
        /// <summary>
        /// Get user from users base by its idNumber.
        /// </summary>
        /// <param name="userId">User's idNumber</param>
        /// <returns>User if exist, null pointer otherwise</returns>
        public static User GetUserById(int userId)
        {
            DataBase db = DataBase.GetInstance();

            db.SetConnections(Constants.PATH);
            db.LoadUsers();

            return(db.GetUserById(userId));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Deletes a user from the database
        /// </summary>
        /// <param name="userId">id of the user to delete</param>
        /// <returns>false if there is no such user in the database</returns>
        public static bool DeleteUser(int userId)
        {
            bool success = false;

            DataBase db = DataBase.GetInstance();

            db.SetConnections(Constants.PATH);
            db.LoadUsers();

            success = db.Users.Remove(db.GetUserById(userId));

            db.CommitUsers();

            return(success);
        }