From 0a89dfda14405bc5b13c5ce6dc1065f33d7f6e35 Mon Sep 17 00:00:00 2001 From: Olli-Antti Kivilahti Date: Thu, 24 Sep 2015 10:16:36 +0300 Subject: [PATCH] Bug 14656 - Delete Bibliographic Records REST API - use C4::Biblio instead :( --- Koha/REST/V1/Biblios.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Koha/REST/V1/Biblios.pm b/Koha/REST/V1/Biblios.pm index 8cc125b..30dda9e 100644 --- a/Koha/REST/V1/Biblios.pm +++ b/Koha/REST/V1/Biblios.pm @@ -5,6 +5,7 @@ use Modern::Perl; use Mojo::Base 'Mojolicious::Controller'; use Koha::Database; +use C4::Biblio; sub delete_biblio { my ($c, $args, $cb) = @_; @@ -16,12 +17,11 @@ sub delete_biblio { return $c->$cb({error => "Biblio not found"}, 404); } - my $itemCount = $schema->resultset('Item')->search({biblionumber => $args->{biblionumber}})->count(); - if ($itemCount) { - return $c->$cb({error => "Biblio has Items attached. Delete them first."}, 400); + my $errors = C4::Biblio::DelBiblio( $args->{biblionumber} ); + if ($errors) { + return $c->$cb({error => $errors}, 400); } - $biblio->delete(); return $c->$cb('', 204); } -- 1.9.1