All right, guys.
The last time we were here, we were setting up our model called Car.
And I believe that I said at the end of that lesson that we would be delving into the nvme pattern.
But before we get there, we need to set up what we call a service.
So that is one folder that I forgot to create.
So let me go ahead and add that.
Let's go to the project, add a new folder, let me call it services.
And then instead of services, we're going to add a new class and this one I'm going to call car service.
Now, the purpose of a service is that it will be the taxi for the application between whatever is the
datastore and the actual application.
Right.
This is a typical design pattern that you would see.
Some times we call it repositories and they have other funds in it.
But essentially the service is just going to be in charge of handling the queries, whether it's a static
data resource or to the database.
For now, we don't have a database, so we're going to create our own resources, our own data sources,
rather.
So the first thing I'm going to do is create a new list inside of this.
Well, I guess I can forego that.
Let's just start off by creating a method that gets us the list of cars, right?
So let's say a public and I'm just going to say return a list of car objects.
I will call it get cars.
That's an easy right and include any missing references.
Of course I'll get cars.
It's expected to return a list of cars.
So what I'll do is just return a new list of car and then we can initialize this list right here.
Now I have these presets, so I'll just add about seven cars to the list and then we can go through
them.
Let me just zoom out so you can see.
So you can see.
I have a remnant of car I.D. there and it just goes around current.
So all I'm doing is just adding some static cars.
Now, this could easily have been a Jason file, that record.
And later on when we look at the database integration, this will become a database query, right?
So this is just some placeholder data so that we can have something to work with.
But essentially you can go ahead and make up your own cars.
I just added a make the model and Vin, I didn't even bother to change the VIN for all the cars.
Right.
Even though that should be very unique.
So you can go ahead, you can pause, you can replicate what I have, or you can just pause and replicate
the structure I have with your own data.
That's really secondary at this point.
Now that is our service.
So once again, our service is going to be in charge of taxiing the data from our data source to whatever
is requesting it.
When we're doing the NVM pattern, it's really the view model that will be requesting data from the
car service.
So we have a database, then we have the car service talking to the database, returning that to our
view model, which will then massage the data and do whatever it needs to do before it returns to the
view and then the car.
Here is our model that just represents that data are are a collection of car would be the collection
of car related required.
So each car object represents the record coming from that data source.
So this is one record, that's another record, etc..
So when we come back, we'll be looking at setting up our view model.