Okay.
Welcome to section two.
And in this section we're going to take a look at some API basics and really start getting our hands
dirty with building this application or at least the beginnings of our application.
So coming up in this particular section what we're going to take a look at.
We're going to take a brief look at what is net.
It's this all encompassing framework that's designed to help us build any type of application.
So we'll take a closer look at that.
We're also going to take a look at what we are building, which is going to be a Rest based API, an
application programming interface that allows our client, our react client, that we're going to build
on the front end to make a query to our back end in the dotnet world and retrieve data from a database
and return it to that client.
In order to create our project, we're going to make use of the dotnet command line interface, which
gives us a bunch of different commands that we can use to do various dotnet related things.
One of them to be to create a template for a web API type of project that we'll be using On our back
end.
Once we have our projects, we're going to take a closer look at it and see what's involved inside that
project and how we start and stop and run our.
Net application.
Following that, we're going to take a look at Entity Framework.
We need a database for our application.
It's going to be database driven.
And we're going to use Entity Framework to help us query our database.
And the database that we're going to use just for development is SQLite.
So please don't worry if you're thinking or a red flag is being raised thinking, well, we can't use
SQLite for production applications, I know, but it is useful for development as I'll explain as we
go along.
And then once we reach certain milestones, we'll save our hard work into source control using git,
which hopefully you have installed on your computer now.
And we'll also save our code into a public repository on the internet called GitHub.
So even if the worst happens, we lose our hard drive, we lose our computer, then our code is still
safe out there on the internet that we can use and clone onto a new computer as and when we choose to
do so.
So what is net?
Well, it's a framework that allows us to build any conceivable type of app that you can think of.
We can build a web application, mobile apps, desktop apps, cloud based apps, artificial intelligence
based apps, and machine learning.
We can build games.
We can build things that run inside fridges, in the internet of things, and really just about anything
that you can conceive, you could technically use.
Net to do so.
So it's big, it is very big.
And we're not going to scratch the surface really of the entire framework.
We're going to use it for a very specific task.
And what is that task.
What are we using it for.
Well it's to build an API.
Now this is taken directly from Microsoft documentation.
And it's got some terms on here that look a bit weird really.
Things like ASP.
Net.
What is that and what's core.
Because I've said that we're using dot net.
Are these the same things or are they different in some way?
Well, Microsoft traditionally are terrible at naming things and dot net.
The current iteration that we're using is really.
Net core that's had a rebranding.
So once upon a time in the windows world there used to be the.
Net framework that would only run on windows machines.
Microsoft a few years back decided to rewrite the whole thing, call it.
Net core, and make it cross-platform and open source.
And that's what everyone uses nowadays, and they've effectively discontinued the original.
Net framework.
So to avoid confusion, they removed the dot.
Net core label and just referred to it as dot net.
So what we still have though, in documentation, in the code that we use sometimes we're still referring
to things called ASP.
Net and ASP stands for Active Server Pages, which is a really old technology for building functional
web pages that's no longer in existence, but the name has been retained.
And you'll typically see ASP when we're using web related parts of the framework that's designed to
help us build web based applications.
So we'll still see things like ASP.
We'll still see things like core when we're writing our code with the packages that we use from.
Net so just something to be aware of, but nothing to be concerned about.
And when it comes to net, I'll just briefly mention.
Net versions.
Currently we're on version nine.
I'm recording this in late 2024, so the current version available is.
Net nine, but Microsoft typically release a major version every November.
So next November it's going to be.
Net ten following that, net 11.
And so on and so forth.
And the even numbered versions of Net these are the ones that are considered long term support, which
means these are supported with stability bug fixes, security updates for three years after its initial
release.
When it comes to the standard releases like Net nine and Net 11, these are supported for 18 months.
What this means in practice is for production based applications.
Then typically you would skip the odd numbered version.
The odd numbered versions are used for new features, typically, and the even numbered ones are more
stability versions that have that long term support.
So for a production application, you're typically not upgraded to Net nine, but you would wait till
Net ten.
So you're really you're looking at a two year cycle for upgrading between Net versions.
We're going to go through Net nine because why not.
It's a training course.
And the application we're building is just a demo application.
It's not going to live and service normal users because we're selling fake products in a store that
doesn't actually exist.
So we're going to use.
Net nine or at least that's what this course is aiming at.
The net ecosystem is made up of many different parts.
We have our languages.
What language do we write our code in?
Well, there's options because we can use C sharp, we can use F sharp and Visual Basic.
And the most commonly used language of these is C sharp, which is an object orientated language that
also supports functional programming.
And it's the most general purpose of the three of them.
F sharp is a functional first programming language and is good for data processing type applications.
Heavy financial math, heavy scientific type applications.
Not something that we're building on this training course.
And Visual Basic is really kind of legacy.
It was geared towards simplicity and readability and was often preferred by developers with a background
in Visual Basic, and that's really retained for legacy purposes.
But since we have different languages, then we have different runtimes that handle those different
languages and the features specific to those languages.
But obviously when it's outputs, it needs to be output into a language our machine can understand.
And we also have the Common Language Runtime that takes care of that.
So whatever language we write our code in, there's something that's going to compile it into something
the machine can understand at the end of it, but we still just use the single.
Net framework to do so.
We also have libraries that come along with dotnet.
DotNet is a framework and there's many libraries encompassed inside that framework.
So there's libraries for things like authentication.
There's libraries for things like forms and HTTP requests.
And it's really such a huge framework.
It's made up of many, many different libraries.
But even that may not be enough.
And we need to get third party library support.
And in which case we can rely on NuGet, which is the package manager for DotNet, which will allow
us to install additional packages not provided by the framework into our application.
And we also have the dotnet command line interface which helps us manage.
Net from a command line.
And for our training course purposes, we're going to be using C-sharp to build our application.
And there could even be a strong argument for saying, well, if you're only going to learn one thing,
then C sharp is a very versatile language, and it is relatively easy to learn because of its strong
support for objects and type safety.
So we're going to be building a web API using C sharp and the.
Net and what is a web API?
Well, it's effectively in our use case HTTP services that are going to be running on top of.
Net and we're going to create things called API controllers that have API endpoints, whose job is to
receive HTTP requests from our client and send back HTTP responses, including the data that we retrieve
from our database.
And to build this API, we're going to be using Rest based protocols, which is really a set of constraints
about how we go about building our API.
And Rest stands for Representational State Transfer.
You'll often hear that mentioned in the same breath as building a web API.
It's really just a set of constraints that we use as developers to provide our API with predictability
and consistency in how we build it and how it's consumed from the client.
So an API, then, if we take our average user, is going to make a request to go and get our web page.
And our web page is going to be a data driven web page made up of, for example, a bunch of products.
But those products don't come down with the HTML that we send back to the client.
They have to be retrieved by the browser, and the browser separately, will go out to our API and make
a request to go and get that data, and it will make an HTTP request.
Our API will receive that request and it will return an HTTP response with hopefully the list of products.
And then our browser can use that list of products depending on the code we write in our react application
to update the user interface.
So that's our goal.
And our purpose in this section is to set up the structure of our application to be able to do such
a thing.
So let's begin.