From 3326dac51ab643e428219f4bb7ca1d09853bd30d Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Sat, 22 Jul 2017 14:29:29 +0200 Subject: [PATCH] Fix creation and update. --- src/scheduler/schedule.controller.ts | 7 +++++-- src/scheduler/schedule.service.ts | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/scheduler/schedule.controller.ts b/src/scheduler/schedule.controller.ts index 37e19a2..ffdafd2 100644 --- a/src/scheduler/schedule.controller.ts +++ b/src/scheduler/schedule.controller.ts @@ -17,6 +17,7 @@ export class ScheduleController{ private $stateParams, private toastrService: ToastrService, private scheduleService: ScheduleService, + private logger: Logger, private $modal ) { // Load operations on controller initialization. @@ -51,9 +52,11 @@ export class ScheduleController{ let subscription: Observable; if(operation.id) { - subscription = this.scheduleService.create(operation); - } else { + this.logger.log("updating schedule", operation); subscription = this.scheduleService.update(operation); + } else { + this.logger.log("creating schedule", operation); + subscription = this.scheduleService.create(operation); } return subscription.subscribe((operation: Schedule) => { diff --git a/src/scheduler/schedule.service.ts b/src/scheduler/schedule.service.ts index fb0d8f1..d29036b 100644 --- a/src/scheduler/schedule.service.ts +++ b/src/scheduler/schedule.service.ts @@ -44,6 +44,6 @@ export class ScheduleService { } delete(schedule: Schedule): Observable { - return this.one(schedule.id).delete(); + return this.one(schedule.id).remove(); } }