Changes between Version 2 and Version 3 of UseCase04


Ignore:
Timestamp:
05/17/26 23:28:59 (8 days ago)
Author:
181201
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • UseCase04

    v2 v3  
    66
    77'''Description:'''
    8 A Pet Owner finds a Pet Sitter they like and requests a booking. The system creates the booking and links the selected pets using a secure database transaction.
     8A Pet Owner finds a Pet Sitter they like and requests a booking. They must select the specific service they want. The system creates the booking and links the requested services using a secure database transaction.
    99
    1010'''Scenario:'''
    11  1. Pet Owner views the profile of a sitter and clicks "Book Now".
    12  2. Owner fills out the dates, location, selects the pets, and submits.
    13  3. System creates the booking with a 'Pending' status:
     11 1. Pet Owner views the profile of a sitter (e.g., `sitter_filip`) and clicks "Book Now".
     12 2. System provides the specific services that this sitter offers to display in the booking form:
    1413{{{
    1514#!sql
    16 INSERT INTO bookings (status, date_from, date_to, address, owner_id, sitter_id)
    17 VALUES (
    18     'Pending', '2026-06-10', '2026-06-12', 'ul. Partizanska br. 10',
    19     (SELECT user_id FROM users WHERE username = 'owner_bojan'),
    20     (SELECT user_id FROM users WHERE username = 'sitter_filip')
    21 );
     15SELECT s.service_id, s.type, s.description
     16FROM services s
     17JOIN sitter_services ss ON s.service_id = ss.service_id
     18WHERE ss.sitter_id = (SELECT user_id FROM users WHERE username = 'sitter_filip');
    2219}}}
     20 3. Owner fills out the dates, location, selects the pets, and submits.
     21 4. System creates the booking with a 'Pending' status and attaches the requested service simultaneously:
     22{{{
     23#!sql
     24BEGIN;
     25
     26WITH new_booking AS (
     27    INSERT INTO bookings (status, date_from, date_to, address, owner_id, sitter_id)
     28    VALUES (
     29        'Pending', '2026-06-10', '2026-06-12', 'ul. Partizanska br. 10',
     30        (SELECT user_id FROM users WHERE username = 'owner_bojan'),
     31        (SELECT user_id FROM users WHERE username = 'sitter_filip')
     32    )
     33    RETURNING booking_id
     34)
     35INSERT INTO booking_services (booking_id, service_id)
     36SELECT nb.booking_id, (SELECT service_id FROM services WHERE type = 'Dog Walking')
     37FROM new_booking nb;
     38
     39COMMIT;
     40}}}