implement class

This commit is contained in:
2025-04-08 16:47:41 -07:00
parent fe2b8b2f69
commit 461b1d1a59

View File

@@ -2,22 +2,35 @@ import { ParkingGetterSetterRepository } from "./ParkingGetterSetterRepository";
import { IParkingStructure } from "../entities/ParkingRepositoryEntities";
export class InMemoryParkingRepository implements ParkingGetterSetterRepository {
private structures: Map<string, IParkingStructure>;
constructor() {
this.structures = new Map<string, IParkingStructure>();
}
async addOrUpdateParkingStructure(structure: IParkingStructure): Promise<void> {
this.structures.set(structure.id, { ...structure });
}
async clearParkingStructureData(): Promise<void> {
this.structures.clear();
}
async getParkingStructureById(id: string): Promise<IParkingStructure | null> {
return null;
const structure = this.structures.get(id);
return structure ? { ...structure } : null;
}
async getParkingStructures(): Promise<IParkingStructure[]> {
return [];
return Array.from(this.structures.values()).map(structure => ({ ...structure }));
}
async removeParkingStructureIfExists(id: string): Promise<IParkingStructure | null> {
const structure = this.structures.get(id);
if (structure) {
this.structures.delete(id);
return { ...structure };
}
return null;
}
}