File

assets/angular/shared/roles-service.ts

Description

Role related service

Author: Shilo Banihit

Index

Methods

Constructor

constructor(http: Http, configService: ConfigService)
Parameters :
Name Type Optional Description
http Http
configService ConfigService

Methods

getBrandRoles
getBrandRoles()
Returns : Promise<[]>
updateUserRoles
updateUserRoles(userid: any, roleIds: any)
Parameters :
Name Type Optional Description
userid any
roleIds any
Returns : any
import { Injectable, Inject} from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/toPromise';
import { BaseService } from '../shared/base-service'
import { SaveResult, Role, User, LoginResult } from './user-models'
import { ConfigService } from './config-service';

/**
 * Role related service
 *
 * Author: <a href='https://github.com/shilob' target='_blank'>Shilo Banihit</a>
 */
@Injectable()
export class RolesService extends BaseService {

  constructor (@Inject(Http) http: Http, @Inject(ConfigService) protected configService: ConfigService) {
    super(http, configService);
  }

  getBrandRoles() :Promise<Role[]> {
    return this.http.get(`${this.brandingAndPortalUrl}/admin/roles/get`, this.options)
    .toPromise()
    .then((res:any) => this.extractData(res) as Role[]);
  }

  updateUserRoles(userid: any, roleIds: any) {
    return this.http.post(`${this.brandingAndPortalUrl}/admin/roles/user`, {userid: userid, roles:roleIds}, this.options)
    .toPromise()
    .then((res:any) => this.extractData(res) as SaveResult[]);
  }
}

results matching ""

    No results matching ""