check if shipmaster is already on the water
This commit is contained in:
@ -62,6 +62,7 @@ pub enum LogbookCreateError {
|
||||
BoatLocked,
|
||||
BoatNotFound,
|
||||
TooManyRowers(usize, usize),
|
||||
ShipmasterAlreadyOnWater,
|
||||
}
|
||||
|
||||
impl Logbook {
|
||||
@ -144,6 +145,10 @@ impl Logbook {
|
||||
if boat.on_water(db).await {
|
||||
return Err(LogbookCreateError::BoatAlreadyOnWater);
|
||||
}
|
||||
if (User::find_by_id(db, log.shipmaster as i32).await.unwrap()).on_water(db).await {
|
||||
return Err(LogbookCreateError::BoatAlreadyOnWater);
|
||||
}
|
||||
|
||||
|
||||
if log.rower.len() > boat.amount_seats as usize - 1 {
|
||||
return Err(LogbookCreateError::TooManyRowers(
|
||||
|
Reference in New Issue
Block a user