pub struct ResourceBookingUseCases { /* private fields */ }Expand description
Use cases for resource booking operations
Orchestrates business logic for community space bookings with conflict detection, owner name enrichment, and authorization checks.
Implementations§
Source§impl ResourceBookingUseCases
impl ResourceBookingUseCases
pub fn new( booking_repo: Arc<dyn ResourceBookingRepository>, owner_repo: Arc<dyn OwnerRepository>, ) -> Self
Sourcepub async fn create_booking(
&self,
booked_by: Uuid,
dto: CreateResourceBookingDto,
) -> Result<ResourceBookingResponseDto, String>
pub async fn create_booking( &self, booked_by: Uuid, dto: CreateResourceBookingDto, ) -> Result<ResourceBookingResponseDto, String>
Sourcepub async fn get_booking(
&self,
booking_id: Uuid,
) -> Result<ResourceBookingResponseDto, String>
pub async fn get_booking( &self, booking_id: Uuid, ) -> Result<ResourceBookingResponseDto, String>
Get booking by ID with owner name enrichment
Sourcepub async fn list_building_bookings(
&self,
building_id: Uuid,
) -> Result<Vec<ResourceBookingResponseDto>, String>
pub async fn list_building_bookings( &self, building_id: Uuid, ) -> Result<Vec<ResourceBookingResponseDto>, String>
List all bookings for a building
Sourcepub async fn list_by_resource_type(
&self,
building_id: Uuid,
resource_type: ResourceType,
) -> Result<Vec<ResourceBookingResponseDto>, String>
pub async fn list_by_resource_type( &self, building_id: Uuid, resource_type: ResourceType, ) -> Result<Vec<ResourceBookingResponseDto>, String>
List bookings by building and resource type
Sourcepub async fn list_by_resource(
&self,
building_id: Uuid,
resource_type: ResourceType,
resource_name: String,
) -> Result<Vec<ResourceBookingResponseDto>, String>
pub async fn list_by_resource( &self, building_id: Uuid, resource_type: ResourceType, resource_name: String, ) -> Result<Vec<ResourceBookingResponseDto>, String>
List bookings for a specific resource (building + type + name)
Sourcepub async fn list_user_bookings(
&self,
user_id: Uuid,
) -> Result<Vec<ResourceBookingResponseDto>, String>
pub async fn list_user_bookings( &self, user_id: Uuid, ) -> Result<Vec<ResourceBookingResponseDto>, String>
List bookings by user (owner who made the booking)
Sourcepub async fn list_user_bookings_by_status(
&self,
user_id: Uuid,
status: BookingStatus,
) -> Result<Vec<ResourceBookingResponseDto>, String>
pub async fn list_user_bookings_by_status( &self, user_id: Uuid, status: BookingStatus, ) -> Result<Vec<ResourceBookingResponseDto>, String>
List bookings by user and status
Sourcepub async fn list_building_bookings_by_status(
&self,
building_id: Uuid,
status: BookingStatus,
) -> Result<Vec<ResourceBookingResponseDto>, String>
pub async fn list_building_bookings_by_status( &self, building_id: Uuid, status: BookingStatus, ) -> Result<Vec<ResourceBookingResponseDto>, String>
List bookings by building and status
Sourcepub async fn list_upcoming_bookings(
&self,
building_id: Uuid,
limit: Option<i64>,
) -> Result<Vec<ResourceBookingResponseDto>, String>
pub async fn list_upcoming_bookings( &self, building_id: Uuid, limit: Option<i64>, ) -> Result<Vec<ResourceBookingResponseDto>, String>
List upcoming bookings (future, confirmed or pending)
Sourcepub async fn list_active_bookings(
&self,
building_id: Uuid,
) -> Result<Vec<ResourceBookingResponseDto>, String>
pub async fn list_active_bookings( &self, building_id: Uuid, ) -> Result<Vec<ResourceBookingResponseDto>, String>
List active bookings (currently in progress)
Sourcepub async fn list_past_bookings(
&self,
building_id: Uuid,
limit: Option<i64>,
) -> Result<Vec<ResourceBookingResponseDto>, String>
pub async fn list_past_bookings( &self, building_id: Uuid, limit: Option<i64>, ) -> Result<Vec<ResourceBookingResponseDto>, String>
List past bookings
Sourcepub async fn update_booking(
&self,
booking_id: Uuid,
updater_id: Uuid,
dto: UpdateResourceBookingDto,
) -> Result<ResourceBookingResponseDto, String>
pub async fn update_booking( &self, booking_id: Uuid, updater_id: Uuid, dto: UpdateResourceBookingDto, ) -> Result<ResourceBookingResponseDto, String>
Update booking details (resource_name, notes)
Time changes require cancellation and rebooking to ensure conflict detection.
§Authorization
- Only booking owner can update their booking
Sourcepub async fn cancel_booking(
&self,
booking_id: Uuid,
canceller_id: Uuid,
) -> Result<ResourceBookingResponseDto, String>
pub async fn cancel_booking( &self, booking_id: Uuid, canceller_id: Uuid, ) -> Result<ResourceBookingResponseDto, String>
Sourcepub async fn complete_booking(
&self,
booking_id: Uuid,
) -> Result<ResourceBookingResponseDto, String>
pub async fn complete_booking( &self, booking_id: Uuid, ) -> Result<ResourceBookingResponseDto, String>
Complete a booking (typically auto-called after end_time)
§Authorization
- Admin only (for manual completion)
Sourcepub async fn mark_no_show(
&self,
booking_id: Uuid,
) -> Result<ResourceBookingResponseDto, String>
pub async fn mark_no_show( &self, booking_id: Uuid, ) -> Result<ResourceBookingResponseDto, String>
Sourcepub async fn confirm_booking(
&self,
booking_id: Uuid,
) -> Result<ResourceBookingResponseDto, String>
pub async fn confirm_booking( &self, booking_id: Uuid, ) -> Result<ResourceBookingResponseDto, String>
Sourcepub async fn delete_booking(
&self,
booking_id: Uuid,
deleter_id: Uuid,
) -> Result<(), String>
pub async fn delete_booking( &self, booking_id: Uuid, deleter_id: Uuid, ) -> Result<(), String>
Delete a booking
§Authorization
- Only booking owner can delete their booking
- Or admin for any booking
Sourcepub async fn check_conflicts(
&self,
building_id: Uuid,
resource_type: ResourceType,
resource_name: String,
start_time: DateTime<Utc>,
end_time: DateTime<Utc>,
exclude_booking_id: Option<Uuid>,
) -> Result<Vec<ResourceBookingResponseDto>, String>
pub async fn check_conflicts( &self, building_id: Uuid, resource_type: ResourceType, resource_name: String, start_time: DateTime<Utc>, end_time: DateTime<Utc>, exclude_booking_id: Option<Uuid>, ) -> Result<Vec<ResourceBookingResponseDto>, String>
Check for booking conflicts
Useful for frontend to preview conflicts before creating booking.
Returns list of conflicting bookings with owner names.
Sourcepub async fn get_statistics(
&self,
building_id: Uuid,
) -> Result<BookingStatisticsDto, String>
pub async fn get_statistics( &self, building_id: Uuid, ) -> Result<BookingStatisticsDto, String>
Get booking statistics for a building
Auto Trait Implementations§
impl Freeze for ResourceBookingUseCases
impl !RefUnwindSafe for ResourceBookingUseCases
impl Send for ResourceBookingUseCases
impl Sync for ResourceBookingUseCases
impl Unpin for ResourceBookingUseCases
impl !UnwindSafe for ResourceBookingUseCases
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Chain<T> for T
impl<T> Chain<T> for T
§impl<T> Fake for T
impl<T> Fake for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more