| | 1 | = UseCase04 - Saves a Listing |
| | 2 | ** Initiating actor: Client ** |
| | 3 | == Description |
| | 4 | A client browses listings and can save a listing into their favourites for quick access later. When the client clicks “Save” on a listing, the system verifies the client is logged in, verifies the listing exists, then stores the favourite record. The client can later view or remove saved listings. |
| | 5 | == Scenario |
| | 6 | 1. Client clicks a listing from the lisiting page. |
| | 7 | {{{ |
| | 8 | SELECT |
| | 9 | l.listing_id, |
| | 10 | l.status, |
| | 11 | l.price, |
| | 12 | l.description, |
| | 13 | l.created_at, |
| | 14 | a.animal_id, |
| | 15 | a.name AS animal_name, |
| | 16 | a.species, |
| | 17 | a.breed, |
| | 18 | a.located_name, |
| | 19 | l.owner_id |
| | 20 | FROM listings l |
| | 21 | JOIN animals a ON a.animal_id = l.animal_id |
| | 22 | WHERE l.listing_id = $1; |
| | 23 | |
| | 24 | }}} |
| | 25 | 2. Client clicks "Save Listing". |
| | 26 | 3. The system saves the listing to favorites to the client. |
| | 27 | {{{ |
| | 28 | INSERT INTO favourite_listings (user_id, listing_id) |
| | 29 | VALUES ($1, $2); |
| | 30 | }}} |
| | 31 | |
| | 32 | |
| | 33 | |
| | 34 | |