|
| 1 | +<!-- a797104c-4286-487d-b23c-da88d8cd0bcd 7a46dcf2-d16e-41c0-94c2-18eaf0961bf9 --> |
| 2 | +# Backend updates: VehicleModels search, soft delete, JSON POST |
| 3 | + |
| 4 | +## Scope |
| 5 | + |
| 6 | +- VehicleModels only |
| 7 | +- Merge GET list and search into one endpoint with nullable `search` |
| 8 | +- Soft delete VehicleModel |
| 9 | +- Create model via JSON body; uploads continue via VehiclePhotosController |
| 10 | + |
| 11 | +## Changes |
| 12 | + |
| 13 | +### 1) Merge GET + search |
| 14 | + |
| 15 | +- File: `VehicleShowroomManagement/src/WebAPI/Controllers/VehicleModelsController.cs` |
| 16 | +- Ensure existing `[HttpGet]` accepts `search?: string` (already added), remove separate `search` GET or deprecate. |
| 17 | +- File: `.../Application/Features/VehicleModels/Queries/GetVehicleModels/GetVehicleModelsQuery.cs` |
| 18 | +- Confirm `Search?: string` exists (done) and propagate. |
| 19 | +- File: `.../Queries/GetVehicleModels/GetVehicleModelsQueryHandler.cs` |
| 20 | +- Already filters by `Search` if provided. Keep pagination. |
| 21 | + |
| 22 | +### 2) Soft delete VehicleModel |
| 23 | + |
| 24 | +- Domain: `VehicleShowroomManagement/src/Domain/Entities/VehicleModel.cs` |
| 25 | +- Add `DateTimeOffset? DeletedAt { get; private set; }` |
| 26 | +- Add method `MarkDeleted()` and guard in constructors/operations if needed. |
| 27 | +- Application: create command `DeleteVehicleModelCommand` to mark soft delete. |
| 28 | +- Files under `.../Features/VehicleModels/Commands/DeleteVehicleModel/*` |
| 29 | +- Handler: fetch by id, set `DeletedAt = UtcNow`, persist. |
| 30 | +- Infrastructure Repository: ensure `GetAllAsync` and queries exclude `DeletedAt != null`. |
| 31 | +- Update repository or handler to filter out deleted models. |
| 32 | +- WebAPI: `VehicleModelsController` |
| 33 | +- Change `HttpDelete("{modelNumber}")` to call soft delete command. |
| 34 | + |
| 35 | +### 3) POST VehicleModel JSON-only |
| 36 | + |
| 37 | +- WebAPI: `VehicleModelsController` |
| 38 | +- Replace `[Consumes("multipart/form-data")]` Create with `[FromBody] CreateVehicleModelRequest` (JSON). |
| 39 | +- Remove in-method file handling and Cloudinary upload logic from Create. |
| 40 | +- Keep upload flows in `VehiclePhotosController` only. |
| 41 | +- Application: `CreateVehicleModelCommand` stays; ensure `ImageUrl`/primary photo is not required. |
| 42 | + |
| 43 | +### 4) Cleanup and deprecation |
| 44 | + |
| 45 | +- `VehicleModelsController`: remove or mark `[HttpGet("search")]` as obsolete and redirect to main GET with `search` param. |
| 46 | +- Ensure all GET handlers exclude soft-deleted items. |
| 47 | + |
| 48 | +## Notes |
| 49 | + |
| 50 | +- No changes to `Vehicles` or `Users` per selection. |
| 51 | +- Frontend will continue to call `GET /api/vehiclemodels?search=...` and separate photo uploads. |
| 52 | +- Backward compatibility: return same DTOs; just omit soft-deleted models. |
| 53 | + |
| 54 | +### To-dos |
| 55 | + |
| 56 | +- [ ] Consolidate VehicleModels GET and remove deprecated search endpoint |
| 57 | +- [ ] Add DeletedAt and MarkDeleted to VehicleModel entity |
| 58 | +- [ ] Add DeleteVehicleModelCommand and handler for soft delete |
| 59 | +- [ ] Exclude soft-deleted models in list and get-by-id queries |
| 60 | +- [ ] Change CreateVehicleModel to JSON body; remove multipart handling |
| 61 | +- [ ] Update README/ENV docs for new usage and deprecations |
0 commit comments