|
Lines 19-25
use Modern::Perl;
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Mojo::Base 'Mojolicious::Controller'; |
20 |
use Mojo::Base 'Mojolicious::Controller'; |
| 21 |
|
21 |
|
| 22 |
use C4::Auth qw( haspermission ); |
|
|
| 23 |
use Koha::City; |
22 |
use Koha::City; |
| 24 |
use Koha::Cities; |
23 |
use Koha::Cities; |
| 25 |
|
24 |
|
|
Lines 37-43
sub list {
Link Here
|
| 37 |
} |
36 |
} |
| 38 |
|
37 |
|
| 39 |
return try { |
38 |
return try { |
| 40 |
$cities = Koha::Cities->search($filter)->unblessed; |
39 |
$cities = Koha::Cities->search($filter); |
| 41 |
return $c->$cb( $cities, 200 ); |
40 |
return $c->$cb( $cities, 200 ); |
| 42 |
} |
41 |
} |
| 43 |
catch { |
42 |
catch { |
|
Lines 59-65
sub get {
Link Here
|
| 59 |
return $c->$cb( { error => "City not found" }, 404 ); |
58 |
return $c->$cb( { error => "City not found" }, 404 ); |
| 60 |
} |
59 |
} |
| 61 |
|
60 |
|
| 62 |
return $c->$cb( $city->unblessed, 200 ); |
61 |
return $c->$cb( $city, 200 ); |
| 63 |
} |
62 |
} |
| 64 |
|
63 |
|
| 65 |
sub add { |
64 |
sub add { |
|
Lines 69-75
sub add {
Link Here
|
| 69 |
|
68 |
|
| 70 |
return try { |
69 |
return try { |
| 71 |
$city->store; |
70 |
$city->store; |
| 72 |
return $c->$cb( $city->unblessed, 200 ); |
71 |
return $c->$cb( $city, 200 ); |
| 73 |
} |
72 |
} |
| 74 |
catch { |
73 |
catch { |
| 75 |
if ( $_->isa('DBIx::Class::Exception') ) { |
74 |
if ( $_->isa('DBIx::Class::Exception') ) { |
|
Lines 91-97
sub update {
Link Here
|
| 91 |
$city = Koha::Cities->find( $args->{cityid} ); |
90 |
$city = Koha::Cities->find( $args->{cityid} ); |
| 92 |
$city->set( $args->{body} ); |
91 |
$city->set( $args->{body} ); |
| 93 |
$city->store(); |
92 |
$city->store(); |
| 94 |
return $c->$cb( $city->unblessed, 200 ); |
93 |
return $c->$cb( $city, 200 ); |
| 95 |
} |
94 |
} |
| 96 |
catch { |
95 |
catch { |
| 97 |
if ( not defined $city ) { |
96 |
if ( not defined $city ) { |
| 98 |
- |
|
|