WEBVTT

00:00.000 --> 00:00.300
Okay.

00:00.300 --> 00:01.590
Welcome to section two.

00:01.590 --> 00:06.510
And in this section we're going to take a look at some API basics and really start getting our hands

00:06.510 --> 00:11.670
dirty with building this application or at least the beginnings of our application.

00:11.670 --> 00:14.910
So coming up in this particular section what we're going to take a look at.

00:14.940 --> 00:17.280
We're going to take a brief look at what is net.

00:17.310 --> 00:22.650
It's this all encompassing framework that's designed to help us build any type of application.

00:22.650 --> 00:24.750
So we'll take a closer look at that.

00:24.780 --> 00:30.270
We're also going to take a look at what we are building, which is going to be a Rest based API, an

00:30.270 --> 00:35.910
application programming interface that allows our client, our react client, that we're going to build

00:35.910 --> 00:42.240
on the front end to make a query to our back end in the dotnet world and retrieve data from a database

00:42.240 --> 00:44.460
and return it to that client.

00:44.640 --> 00:50.280
In order to create our project, we're going to make use of the dotnet command line interface, which

00:50.280 --> 00:54.810
gives us a bunch of different commands that we can use to do various dotnet related things.

00:54.810 --> 01:02.420
One of them to be to create a template for a web API type of project that we'll be using On our back

01:02.450 --> 01:03.290
end.

01:03.500 --> 01:08.780
Once we have our projects, we're going to take a closer look at it and see what's involved inside that

01:08.780 --> 01:12.080
project and how we start and stop and run our.

01:12.290 --> 01:13.850
Net application.

01:13.880 --> 01:16.550
Following that, we're going to take a look at Entity Framework.

01:16.550 --> 01:18.260
We need a database for our application.

01:18.260 --> 01:19.880
It's going to be database driven.

01:19.880 --> 01:24.110
And we're going to use Entity Framework to help us query our database.

01:24.110 --> 01:28.550
And the database that we're going to use just for development is SQLite.

01:28.940 --> 01:34.490
So please don't worry if you're thinking or a red flag is being raised thinking, well, we can't use

01:34.490 --> 01:40.220
SQLite for production applications, I know, but it is useful for development as I'll explain as we

01:40.220 --> 01:41.030
go along.

01:41.060 --> 01:47.060
And then once we reach certain milestones, we'll save our hard work into source control using git,

01:47.060 --> 01:50.150
which hopefully you have installed on your computer now.

01:50.150 --> 01:55.640
And we'll also save our code into a public repository on the internet called GitHub.

01:55.640 --> 02:01.100
So even if the worst happens, we lose our hard drive, we lose our computer, then our code is still

02:01.100 --> 02:07.320
safe out there on the internet that we can use and clone onto a new computer as and when we choose to

02:07.350 --> 02:08.160
do so.

02:08.190 --> 02:10.230
So what is net?

02:10.260 --> 02:17.220
Well, it's a framework that allows us to build any conceivable type of app that you can think of.

02:17.340 --> 02:22.710
We can build a web application, mobile apps, desktop apps, cloud based apps, artificial intelligence

02:22.710 --> 02:24.360
based apps, and machine learning.

02:24.390 --> 02:25.530
We can build games.

02:25.530 --> 02:31.470
We can build things that run inside fridges, in the internet of things, and really just about anything

02:31.470 --> 02:34.170
that you can conceive, you could technically use.

02:34.350 --> 02:35.430
Net to do so.

02:35.460 --> 02:38.340
So it's big, it is very big.

02:38.340 --> 02:43.230
And we're not going to scratch the surface really of the entire framework.

02:43.230 --> 02:45.540
We're going to use it for a very specific task.

02:45.540 --> 02:47.010
And what is that task.

02:47.010 --> 02:48.360
What are we using it for.

02:48.390 --> 02:49.890
Well it's to build an API.

02:49.920 --> 02:53.010
Now this is taken directly from Microsoft documentation.

02:53.010 --> 02:57.180
And it's got some terms on here that look a bit weird really.

02:57.210 --> 02:59.970
Things like ASP.

03:00.750 --> 03:01.350
Net.

03:01.380 --> 03:04.290
What is that and what's core.

03:04.320 --> 03:06.930
Because I've said that we're using dot net.

03:06.960 --> 03:09.960
Are these the same things or are they different in some way?

03:09.990 --> 03:15.480
Well, Microsoft traditionally are terrible at naming things and dot net.

03:15.510 --> 03:18.690
The current iteration that we're using is really.

03:18.930 --> 03:21.540
Net core that's had a rebranding.

03:21.840 --> 03:24.750
So once upon a time in the windows world there used to be the.

03:24.930 --> 03:27.810
Net framework that would only run on windows machines.

03:27.840 --> 03:32.340
Microsoft a few years back decided to rewrite the whole thing, call it.

03:32.490 --> 03:35.940
Net core, and make it cross-platform and open source.

03:35.940 --> 03:40.020
And that's what everyone uses nowadays, and they've effectively discontinued the original.

03:40.200 --> 03:41.310
Net framework.

03:41.340 --> 03:44.250
So to avoid confusion, they removed the dot.

03:44.580 --> 03:48.870
Net core label and just referred to it as dot net.

03:49.560 --> 03:54.570
So what we still have though, in documentation, in the code that we use sometimes we're still referring

03:54.600 --> 03:55.800
to things called ASP.

03:55.830 --> 04:02.070
Net and ASP stands for Active Server Pages, which is a really old technology for building functional

04:02.070 --> 04:07.940
web pages that's no longer in existence, but the name has been retained.

04:07.940 --> 04:15.740
And you'll typically see ASP when we're using web related parts of the framework that's designed to

04:15.770 --> 04:18.170
help us build web based applications.

04:18.170 --> 04:20.270
So we'll still see things like ASP.

04:20.300 --> 04:26.240
We'll still see things like core when we're writing our code with the packages that we use from.

04:26.450 --> 04:31.190
Net so just something to be aware of, but nothing to be concerned about.

04:31.190 --> 04:33.740
And when it comes to net, I'll just briefly mention.

04:33.920 --> 04:34.730
Net versions.

04:34.730 --> 04:36.620
Currently we're on version nine.

04:36.620 --> 04:41.300
I'm recording this in late 2024, so the current version available is.

04:41.450 --> 04:45.680
Net nine, but Microsoft typically release a major version every November.

04:45.680 --> 04:47.090
So next November it's going to be.

04:47.240 --> 04:49.970
Net ten following that, net 11.

04:49.970 --> 04:52.130
And so on and so forth.

04:52.730 --> 04:59.120
And the even numbered versions of Net these are the ones that are considered long term support, which

04:59.120 --> 05:05.620
means these are supported with stability bug fixes, security updates for three years after its initial

05:05.620 --> 05:06.310
release.

05:06.310 --> 05:11.920
When it comes to the standard releases like Net nine and Net 11, these are supported for 18 months.

05:11.980 --> 05:15.670
What this means in practice is for production based applications.

05:15.670 --> 05:19.030
Then typically you would skip the odd numbered version.

05:19.030 --> 05:25.180
The odd numbered versions are used for new features, typically, and the even numbered ones are more

05:25.180 --> 05:28.210
stability versions that have that long term support.

05:29.110 --> 05:34.360
So for a production application, you're typically not upgraded to Net nine, but you would wait till

05:34.510 --> 05:35.050
Net ten.

05:35.050 --> 05:39.550
So you're really you're looking at a two year cycle for upgrading between Net versions.

05:39.550 --> 05:41.650
We're going to go through Net nine because why not.

05:41.680 --> 05:42.580
It's a training course.

05:42.580 --> 05:46.960
And the application we're building is just a demo application.

05:46.960 --> 05:52.630
It's not going to live and service normal users because we're selling fake products in a store that

05:52.630 --> 05:54.100
doesn't actually exist.

05:54.100 --> 05:54.940
So we're going to use.

05:55.090 --> 05:58.540
Net nine or at least that's what this course is aiming at.

05:58.630 --> 06:02.440
The net ecosystem is made up of many different parts.

06:02.440 --> 06:03.460
We have our languages.

06:03.460 --> 06:05.770
What language do we write our code in?

06:05.770 --> 06:11.360
Well, there's options because we can use C sharp, we can use F sharp and Visual Basic.

06:11.360 --> 06:18.140
And the most commonly used language of these is C sharp, which is an object orientated language that

06:18.140 --> 06:21.230
also supports functional programming.

06:22.160 --> 06:24.800
And it's the most general purpose of the three of them.

06:24.830 --> 06:30.410
F sharp is a functional first programming language and is good for data processing type applications.

06:30.410 --> 06:34.370
Heavy financial math, heavy scientific type applications.

06:34.370 --> 06:36.650
Not something that we're building on this training course.

06:36.650 --> 06:39.380
And Visual Basic is really kind of legacy.

06:39.410 --> 06:46.010
It was geared towards simplicity and readability and was often preferred by developers with a background

06:46.010 --> 06:49.970
in Visual Basic, and that's really retained for legacy purposes.

06:50.240 --> 06:55.040
But since we have different languages, then we have different runtimes that handle those different

06:55.040 --> 06:57.770
languages and the features specific to those languages.

06:57.770 --> 07:03.290
But obviously when it's outputs, it needs to be output into a language our machine can understand.

07:03.320 --> 07:08.030
And we also have the Common Language Runtime that takes care of that.

07:08.720 --> 07:13.400
So whatever language we write our code in, there's something that's going to compile it into something

07:13.400 --> 07:17.060
the machine can understand at the end of it, but we still just use the single.

07:17.240 --> 07:18.920
Net framework to do so.

07:18.980 --> 07:22.250
We also have libraries that come along with dotnet.

07:22.370 --> 07:27.170
DotNet is a framework and there's many libraries encompassed inside that framework.

07:27.170 --> 07:29.690
So there's libraries for things like authentication.

07:29.690 --> 07:32.810
There's libraries for things like forms and HTTP requests.

07:32.810 --> 07:35.690
And it's really such a huge framework.

07:35.690 --> 07:38.210
It's made up of many, many different libraries.

07:38.210 --> 07:40.160
But even that may not be enough.

07:40.160 --> 07:42.560
And we need to get third party library support.

07:42.560 --> 07:47.810
And in which case we can rely on NuGet, which is the package manager for DotNet, which will allow

07:47.810 --> 07:53.390
us to install additional packages not provided by the framework into our application.

07:53.390 --> 07:57.350
And we also have the dotnet command line interface which helps us manage.

07:57.560 --> 07:59.060
Net from a command line.

07:59.060 --> 08:05.870
And for our training course purposes, we're going to be using C-sharp to build our application.

08:06.080 --> 08:10.230
And there could even be a strong argument for saying, well, if you're only going to learn one thing,

08:10.230 --> 08:15.420
then C sharp is a very versatile language, and it is relatively easy to learn because of its strong

08:15.420 --> 08:17.730
support for objects and type safety.

08:17.910 --> 08:21.960
So we're going to be building a web API using C sharp and the.

08:22.170 --> 08:24.540
Net and what is a web API?

08:24.570 --> 08:30.810
Well, it's effectively in our use case HTTP services that are going to be running on top of.

08:30.990 --> 08:37.950
Net and we're going to create things called API controllers that have API endpoints, whose job is to

08:37.980 --> 08:45.420
receive HTTP requests from our client and send back HTTP responses, including the data that we retrieve

08:45.420 --> 08:46.920
from our database.

08:46.920 --> 08:53.340
And to build this API, we're going to be using Rest based protocols, which is really a set of constraints

08:53.340 --> 08:56.280
about how we go about building our API.

08:56.280 --> 09:00.510
And Rest stands for Representational State Transfer.

09:00.540 --> 09:05.070
You'll often hear that mentioned in the same breath as building a web API.

09:05.070 --> 09:10.630
It's really just a set of constraints that we use as developers to provide our API with predictability

09:10.630 --> 09:15.340
and consistency in how we build it and how it's consumed from the client.

09:15.790 --> 09:22.060
So an API, then, if we take our average user, is going to make a request to go and get our web page.

09:22.060 --> 09:28.240
And our web page is going to be a data driven web page made up of, for example, a bunch of products.

09:28.240 --> 09:32.380
But those products don't come down with the HTML that we send back to the client.

09:32.380 --> 09:38.920
They have to be retrieved by the browser, and the browser separately, will go out to our API and make

09:38.950 --> 09:45.160
a request to go and get that data, and it will make an HTTP request.

09:45.190 --> 09:52.600
Our API will receive that request and it will return an HTTP response with hopefully the list of products.

09:52.600 --> 09:58.630
And then our browser can use that list of products depending on the code we write in our react application

09:58.630 --> 10:00.250
to update the user interface.

10:00.250 --> 10:01.030
So that's our goal.

10:01.030 --> 10:07.450
And our purpose in this section is to set up the structure of our application to be able to do such

10:07.480 --> 10:08.410
a thing.

10:08.410 --> 10:10.030
So let's begin.
