View | Details | Raw Unified | Return to bug 14656
Collapse All | Expand All

(-)a/Koha/REST/V1/Biblios.pm (-5 / +4 lines)
Lines 5-10 use Modern::Perl; Link Here
5
use Mojo::Base 'Mojolicious::Controller';
5
use Mojo::Base 'Mojolicious::Controller';
6
6
7
use Koha::Database;
7
use Koha::Database;
8
use C4::Biblio;
8
9
9
sub delete_biblio {
10
sub delete_biblio {
10
    my ($c, $args, $cb) = @_;
11
    my ($c, $args, $cb) = @_;
Lines 16-27 sub delete_biblio { Link Here
16
        return $c->$cb({error => "Biblio not found"}, 404);
17
        return $c->$cb({error => "Biblio not found"}, 404);
17
    }
18
    }
18
19
19
    my $itemCount = $schema->resultset('Item')->search({biblionumber => $args->{biblionumber}})->count();
20
    my $errors = C4::Biblio::DelBiblio( $args->{biblionumber} );
20
    if ($itemCount) {
21
    if ($errors) {
21
        return $c->$cb({error => "Biblio has Items attached. Delete them first."}, 400);
22
        return $c->$cb({error => $errors}, 400);
22
    }
23
    }
23
24
24
    $biblio->delete();
25
    return $c->$cb('', 204);
25
    return $c->$cb('', 204);
26
}
26
}
27
27
28
- 

Return to bug 14656