Overview
TheRepositoryCoches class provides data access methods for managing a collection of cars. It contains an in-memory list of cars and methods to retrieve and search for car records.
Namespace: MvcCoreUtilidades.Repositories
Constructor
RepositoryCoches class with a predefined list of cars. The repository is initialized with four sample cars:
- Pontiac Firebird (IdCoche: 1)
- Volkswagen Escarabajo (IdCoche: 2)
- Ferrari Testarrosa (IdCoche: 3)
- Ford Mustang GT (IdCoche: 4)
Properties
Cars
Methods
GetCoches
List<Coche> - A list containing all car records
Usage:
FindCoche
The unique identifier of the car to find
Coche - The car object with the specified ID, or null if not found
Usage:
Dependency Injection
Register the repository as a singleton or scoped service in yourProgram.cs:
Sample Data
The repository contains the following cars by default:| IdCoche | Marca | Modelo | Imagen |
|---|---|---|---|
| 1 | Pontiac | Firebird | [Image URL] |
| 2 | Volkswagen | Escarabajo | [Image URL] |
| 3 | Ferrari | Testarrosa | [Image URL] |
| 4 | Ford | Mustang GT | [Image URL] |