1 |
package App::RoomReservation::Reservation::Confirmation; |
2 |
use Moose; |
3 |
|
4 |
extends 'App::RoomReservation'; |
5 |
|
6 |
has token => ( |
7 |
is => 'ro', |
8 |
isa => 'Str', |
9 |
required => 1, |
10 |
); |
11 |
|
12 |
sub verify_as_markup { |
13 |
my ($self) = @_; |
14 |
|
15 |
my $sth = $self->dbh->prepare(qq{ |
16 |
update reservation set _confirmed = true |
17 |
where md5(id||email) = ? and _confirmed is false |
18 |
}); |
19 |
$sth->execute( $self->token ); |
20 |
|
21 |
if ( $sth->rows == 1 ) { |
22 |
qq|Your <em>reservation has been confirmed</em> and seat is waiting for you|; |
23 |
} else { |
24 |
qq|We have problem with your confirmation| |
25 |
} |
26 |
} |
27 |
|
28 |
sub cancel_as_markup { |
29 |
my ($self) = @_; |
30 |
|
31 |
my $sth = $self->dbh->prepare(qq{ |
32 |
update reservation set _confirmed = false |
33 |
where md5(id||email) = ? and _confirmed is true |
34 |
}); |
35 |
$sth->execute( $self->token ); |
36 |
|
37 |
if ( $sth->rows == 1 ) { |
38 |
qq|Your <em>reservation is canceled</em>, thanks for your effort to provide seat to somebody else|; |
39 |
} else { |
40 |
qq|We have problem with cancelation| |
41 |
} |
42 |
} |
43 |
|
44 |
1; |