2017-07-22 11:11:39 +02:00
|
|
|
// 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<Schedule[]> {
|
|
|
|
return this.all().getList({
|
|
|
|
account_id: accountId
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
get(accountId: number, id: number): Observable<Schedule> {
|
|
|
|
return this.one(id).get({
|
|
|
|
account_id: accountId
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
create(schedule: Schedule): Observable<Schedule> {
|
|
|
|
return this.all().post(schedule);
|
|
|
|
}
|
|
|
|
|
|
|
|
update(schedule: Schedule): Observable<Schedule> {
|
|
|
|
return this.one(schedule.id).post(null, schedule);
|
|
|
|
}
|
|
|
|
|
|
|
|
delete(schedule: Schedule): Observable<Schedule> {
|
2017-07-22 14:29:29 +02:00
|
|
|
return this.one(schedule.id).remove();
|
2017-07-22 11:11:39 +02:00
|
|
|
}
|
|
|
|
}
|