#include "UIxAppointmentView.h"
#include <NGiCal/NGiCal.h>
#include <SOGoLogic/SOGoAppointment.h>
+#include <Appointments/SOGoAppointmentObject.h>
#include <SOGoUI/SOGoDateFormatter.h>
#include "common.h"
return self;
}
+- (BOOL)isDeletableClientObject {
+ return [[self clientObject] respondsToSelector:@selector(delete)];
+}
+
+- (id)deleteAction {
+ NSException *ex;
+
+ if ([self appointment] == nil) {
+ return [NSException exceptionWithHTTPStatus:404 /* Not Found */
+ reason:@"could not locate appointment"];
+ }
+
+ if (![self isDeletableClientObject]) {
+ /* return 400 == Bad Request */
+ return [NSException exceptionWithHTTPStatus:400
+ reason:@"method cannot be invoked on "
+ @"the specified object"];
+ }
+
+ if ((ex = [[self clientObject] delete]) != nil) {
+ // TODO: improve error handling
+ [self debugWithFormat:@"failed to delete: %@", ex];
+ return ex;
+ }
+
+#warning TODO: fix redirect
+ return [[[self clientObject] container] baseURLInContext:[self context]];
+}
+
@end /* UIxAppointmentView */