import { Injectable } from '@angular/core' ; import { AuthCredentials } from '../model/auth-credentials' ; import { ApiService } from './api.service' ; import { AuthService } from './auth.service' ; import { User } from '../model/user' ; import { UserPreferences } from '../model/user-preferences' ; @ Injectable ( ) export class UserService { constructor ( private authService , private apiService ) { } registerUser ( user ) { return this . apiService . registerUser ( user ) ; } getUser ( ) { return this . apiService . getUser ( this . authService . getUserId ( ) ) ; } getAllUsers ( ) { return this . apiService . getAllUsers ( ) . map ( response => { response . users . sort ( ( now , next ) => { return now . username > next . username ? 1 : - 1 ; } ) ; return response ; } ) ; } deleteUser ( userId ) { return this . apiService . deleteUser ( userId ) ; } clearUserData ( userId ) { return this . apiService . clearUserData ( userId ) ; } promoteUser ( userId ) { return this . apiService . promoteUser ( userId ) ; } demoteUser ( userId ) { return this . apiService . demoteUser ( userId ) ; } updateUserPreferences ( userId , userPreferences ) { return this . apiService . updateUserPreferences ( userId , userPreferences ) ; } }