// vim: set tw=80 ts=2 sw=2 sts=2 : import { Injectable } from '@angular/core'; import { Observable } from 'rxjs/Rx'; import { Restangular } from "ngx-restangular"; import { Schedule } from './schedule'; @Injectable() export class ScheduleService { constructor( private restangular: Restangular ) {} private all() { //return this.accountService.one(accountId).all('scheduled_operation'); return this.restangular.all('scheduled_operation'); } private one(id: number) { //return this.accountService.one(accountId).one('scheduled_operation', id); return this.restangular.one('scheduled_operation', id); } query(accountId: number): Observable { return this.all().getList({ account_id: accountId }); } get(accountId: number, id: number): Observable { return this.one(id).get({ account_id: accountId }); } create(schedule: Schedule): Observable { return this.all().post(schedule); } update(schedule: Schedule): Observable { return this.one(schedule.id).post(null, schedule); } delete(schedule: Schedule): Observable { return this.one(schedule.id).delete(); } }