1
00:00:01,740 --> 00:00:08,130
First definition and stands for model view controller.

2
00:00:08,730 --> 00:00:14,220
But what are these concepts and how are they related to each other?

3
00:00:14,940 --> 00:00:21,840
A model is just a C sharp claws that represents a table in the school server in this case.

4
00:00:22,260 --> 00:00:28,950
So basically serves as a data blueprint and can also be used to define the data relations.

5
00:00:29,700 --> 00:00:36,120
So, for example, in our app, we have producers, we have movies, we have actors, etc. Now to store

6
00:00:36,120 --> 00:00:40,770
all this data in our database, we need to create tables and to create tables.

7
00:00:40,770 --> 00:00:42,840
We are going to create the models.

8
00:00:43,080 --> 00:00:48,600
So, for example, we are going to have producer, model, movie model, actor, etc.

9
00:00:49,790 --> 00:00:53,720
A view is a name already indicates is what the user gets to see.

10
00:00:54,020 --> 00:00:58,340
So it is a file that represents the user interface.

11
00:00:58,640 --> 00:01:01,010
And an MVC view is a C.

12
00:01:01,060 --> 00:01:03,530
S HD Amalfi, where C.

13
00:01:03,530 --> 00:01:09,440
S stands for C Sharp and HD ammo for the HDMI code.

14
00:01:09,860 --> 00:01:18,260
So the C sharp HTML files or the razor views, as we call them, are just a combination of the C sharp

15
00:01:18,590 --> 00:01:21,150
and the HDMI code from The View.

16
00:01:21,170 --> 00:01:27,740
You can trigger the request or the events that get handled by the controllers.

17
00:01:28,190 --> 00:01:34,310
Now, a controller will receive the events, then will prepare a response, and then just return the

18
00:01:34,310 --> 00:01:35,930
response to the view.

19
00:01:36,440 --> 00:01:42,110
A controller is just a C sharp claws that inherits from the controller base class.

20
00:01:42,620 --> 00:01:49,460
Throughout this course, you are going to create producer controller, movie controller, actors, controller,

21
00:01:49,970 --> 00:01:57,650
etc. But how are the views, the models and the controllers related to each other now to better understand

22
00:01:57,650 --> 00:01:58,230
the MVC?

23
00:01:58,250 --> 00:02:01,040
Let us first think as an example, a Web application.

24
00:02:01,790 --> 00:02:07,490
Now, in a Web application, you have a browser, you have the server and a database.

25
00:02:08,330 --> 00:02:12,110
The way these components work with each other is that you sent a request from the browser.

26
00:02:12,200 --> 00:02:14,510
You send it from the browser to the server.

27
00:02:15,200 --> 00:02:18,410
Then the server will gather data from the database.

28
00:02:18,860 --> 00:02:27,230
And once the data is ready, this server will return the data to the browser the same way in MVC.

29
00:02:27,620 --> 00:02:29,660
Now, instead of a browser, you have a view.

30
00:02:30,580 --> 00:02:35,800
Then instead of a server, you have a controller and then instead of the database, you have the models

31
00:02:35,800 --> 00:02:38,530
which are used to communicate with the database.

32
00:02:39,190 --> 00:02:43,910
So let us see the user clicks on a button or just searches for a movie.

33
00:02:43,930 --> 00:02:49,000
In our case, then the request will be sent from the view to the controller.

34
00:02:49,660 --> 00:02:55,180
Then the controller will get the request based on the parameters or no parameters at all.

35
00:02:55,420 --> 00:03:00,730
We'll construct a response by getting some data from the database using models.

36
00:03:01,270 --> 00:03:06,160
And once the response is ready, the response will be returned to The View.

37
00:03:07,380 --> 00:03:10,020
So let us go to the EP that we're going to build.

38
00:03:10,650 --> 00:03:16,260
So when you first seen here is The View song here we have, for example, in our EP, we have a view

39
00:03:16,290 --> 00:03:18,390
that is used to display all the movies.

40
00:03:18,690 --> 00:03:24,630
But if you go to, for example, the show details, this is another view that is used to return data.

41
00:03:24,780 --> 00:03:29,670
So basically, when you are in the movies and then click in here, these show details.

42
00:03:30,060 --> 00:03:33,000
So I'm now sending a request to a controller.

43
00:03:33,600 --> 00:03:35,220
The controller will get the request.

44
00:03:35,250 --> 00:03:40,190
So in this case, is the home controller details action result?

45
00:03:40,200 --> 00:03:47,010
And if Parmeter is the ID number three, it will get some data from the database by using the models,

46
00:03:47,020 --> 00:03:48,090
the necessary models.

47
00:03:48,630 --> 00:03:51,570
And then we turn the response to the view.

48
00:03:51,930 --> 00:03:57,180
So you basically have a controller which will get a request from the view, use the models to get some

49
00:03:57,180 --> 00:04:02,820
data from the database and then return another view, or it can be the same view with some data.
dịch sang tiếng việt chuẩn nhất