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::Members qw( ModMember ); |
|
|
23 |
use Koha::Patrons; |
22 |
use Koha::Patrons; |
24 |
|
23 |
|
25 |
use Scalar::Util qw(blessed); |
24 |
use Scalar::Util qw(blessed); |
Lines 196-218
sub update {
Link Here
|
196 |
return try { |
195 |
return try { |
197 |
my $body = _to_model($c->validation->param('body')); |
196 |
my $body = _to_model($c->validation->param('body')); |
198 |
|
197 |
|
199 |
## TODO: Use ModMember until it has been moved to Koha-namespace |
198 |
$patron->set($body)->store; |
200 |
# Add borrowernumber to $body, as required by ModMember |
199 |
$patron->discard_changes; |
201 |
$body->{borrowernumber} = $patron_id; |
200 |
return $c->render( status => 200, openapi => $patron ); |
202 |
|
|
|
203 |
if ( ModMember(%$body) ) { |
204 |
# Fetch the updated Koha::Patron object |
205 |
$patron->discard_changes; |
206 |
return $c->render( status => 200, openapi => $patron ); |
207 |
} |
208 |
else { |
209 |
return $c->render( |
210 |
status => 500, |
211 |
openapi => { |
212 |
error => 'Something went wrong, check Koha logs for details.' |
213 |
} |
214 |
); |
215 |
} |
216 |
} |
201 |
} |
217 |
catch { |
202 |
catch { |
218 |
unless ( blessed $_ && $_->can('rethrow') ) { |
203 |
unless ( blessed $_ && $_->can('rethrow') ) { |
219 |
- |
|
|