| | 1 | = Use-case 0003 Implementation - Create Unit Listing |
| | 2 | |
| | 3 | '''Initiating actor: ''' Admin |
| | 4 | |
| | 5 | '''Other actors:''' None |
| | 6 | |
| | 7 | '''Description:''' |
| | 8 | |
| | 9 | The admin adds new apartment units to the system after a floor has been created. This includes entering all unit details such as unit number, room count, area, price, and uploading images. The unit becomes available for agents to show to clients. |
| | 10 | |
| | 11 | == Scenario |
| | 12 | |
| | 13 | === Step 1 |
| | 14 | |
| | 15 | '''User action:''' Admin navigates to building management. |
| | 16 | |
| | 17 | '''Screenshot:''' [[Image(0003-1.png)]] |
| | 18 | |
| | 19 | === Step 2 |
| | 20 | |
| | 21 | '''System action:''' System displays all buildings managed by this admin. |
| | 22 | |
| | 23 | '''Query:''' |
| | 24 | {{{ |
| | 25 | SET search_path TO project; |
| | 26 | |
| | 27 | SELECT building_id, name, address, description |
| | 28 | FROM building |
| | 29 | WHERE admin_id = (SELECT admin_id FROM admin WHERE name = 'Nikola') |
| | 30 | ORDER BY name; |
| | 31 | }}} |
| | 32 | |
| | 33 | '''Screenshot:''' [[Image(0003-2.png)]] |
| | 34 | |
| | 35 | * Note selecting an admin by name is only for the prototype, this design poses serious issues if used in a production application. |
| | 36 | |
| | 37 | === Step 3 |
| | 38 | |
| | 39 | '''User action:''' Admin selects "Golden Tower" building. |
| | 40 | |
| | 41 | '''Screenshot:''' [[Image(0003-3.png)]] |
| | 42 | |
| | 43 | === Step 4 |
| | 44 | |
| | 45 | '''System action: ''' System shows all floors in the selected building. |
| | 46 | |
| | 47 | '''Query:''' |
| | 48 | {{{ |
| | 49 | SET search_path TO project; |
| | 50 | |
| | 51 | SELECT floor_id, floor_number, layout_image |
| | 52 | FROM floor |
| | 53 | WHERE building_id = (SELECT building_id FROM building WHERE name = 'Golden Tower') |
| | 54 | ORDER BY floor_number; |
| | 55 | }}} |
| | 56 | |
| | 57 | '''Screenshot:''' [[Image(0003-4.png)]] |
| | 58 | |
| | 59 | === Step 5 |
| | 60 | |
| | 61 | '''User action:''' Admin selects Floor 1 and clicks to add a new unit. |
| | 62 | |
| | 63 | '''Screenshot:''' [[Image(0003-5.png)]] |
| | 64 | |
| | 65 | === Step 6 |
| | 66 | |
| | 67 | '''System action:''' System displays a form with fields: unit number, room number, floor area, price, status, images. |
| | 68 | |
| | 69 | '''Screenshot:''' [[Image(0003-6.png)]] |
| | 70 | |
| | 71 | === Step 7 |
| | 72 | |
| | 73 | '''User action: ''' Admin enters unit details: |
| | 74 | * Unit Number: 104 |
| | 75 | * Room Number: 2 |
| | 76 | * Floor Area: 90 m² |
| | 77 | * Price: 150000 EUR |
| | 78 | * Status: Available |
| | 79 | * Uploads images (unit image, floorplan, vector image) |
| | 80 | |
| | 81 | '''Screenshot:''' [[Image(0003-7.png)]] |
| | 82 | |
| | 83 | === Step 8 |
| | 84 | |
| | 85 | '''User action:''' Admin submits the form. |
| | 86 | |
| | 87 | '''Screenshot:''' [[Image(0003-8.png)]] |
| | 88 | |
| | 89 | === Step 9 |
| | 90 | |
| | 91 | '''System action:''' System validates that unit number doesn't already exist. |
| | 92 | |
| | 93 | '''Query:''' |
| | 94 | {{{ |
| | 95 | SET search_path TO project; |
| | 96 | |
| | 97 | SELECT COUNT(*) |
| | 98 | FROM unit |
| | 99 | WHERE floor_id = ( |
| | 100 | SELECT floor_id FROM floor |
| | 101 | WHERE building_id = (SELECT building_id FROM building WHERE name = 'Golden Tower') |
| | 102 | AND floor_number = 1 |
| | 103 | ) |
| | 104 | AND unit_number = '104'; |
| | 105 | }}} |
| | 106 | |
| | 107 | === Step 10 |
| | 108 | |
| | 109 | '''System action:''' System inserts the new unit. |
| | 110 | |
| | 111 | '''Query:''' |
| | 112 | {{{ |
| | 113 | SET search_path TO project; |
| | 114 | |
| | 115 | INSERT INTO unit(unit_number, room_number, floor_area, status, price, image, floorplan, vector_image, floor_id, admin_id) |
| | 116 | VALUES ( |
| | 117 | '104', |
| | 118 | 2, |
| | 119 | 82.50, |
| | 120 | 'Available', |
| | 121 | 95000.00, |
| | 122 | 'unit_104.jpg', |
| | 123 | 'plan_104.pdf', |
| | 124 | 'vector_104.svg', |
| | 125 | (SELECT floor_id FROM floor |
| | 126 | WHERE building_id = (SELECT building_id FROM building WHERE name = 'Golden Tower') |
| | 127 | AND floor_number = 1), |
| | 128 | (SELECT admin_id FROM admin WHERE name = 'Nikola') |
| | 129 | ); |
| | 130 | }}} |
| | 131 | |
| | 132 | === Step 11 |
| | 133 | |
| | 134 | '''System action:''' System confirms successful creation and displays the unit details. |
| | 135 | |
| | 136 | '''Screenshot:''' [[Image(0003-9.png)]] |