1 00:00:01,740 --> 00:00:08,130 First definition and stands for model view controller. 2…
- User
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.
- Assistant
Mô hình MVC (Model-View-Controller) là một kiến trúc phát triển phần mềm phổ biến được sử dụng để xây dựng ứng dụng web. Trong mô hình này, chúng ta chia ứng dụng thành ba phần chính:
- Model: Đại diện cho dữ liệu và quy tắc xử lý dữ liệu. Dùng để tạo bảng và quan hệ dữ liệu trong cơ sở dữ liệu.
- View: Đại diện cho giao diện người dùng. Dùng để hiển thị thông tin cho người dùng.
- Controller: Đại diện cho logic xử lý và điều khiển ứng dụng. Nhận yêu cầu từ view, truy cập vào model để lấy dữ liệu và trả về view để hiển thị thông tin.
Khi người dùng tương tác với ứng dụng, yêu cầu sẽ được gửi từ view tới controller. Controller sẽ xử lý yêu cầu này bằng cách truy xuất dữ liệu từ model và trả về kết quả tương ứng cho view. View sẽ hiển thị dữ liệu mà controller trả về cho người dùng.
Ví dụ, khi người dùng click vào một nút để xem chi tiết về một bộ phim, view sẽ gửi yêu cầu này tới controller. Controller sẽ lấy dữ liệu từ model (các model được tạo để truy cập và tương tác với cơ sở dữ liệu) và trả về view tương ứng để hiển thị thông tin chi tiết về bộ phim.
Mô hình MVC cho phép chúng ta tách biệt logic xử lý dữ liệu, giao diện người dùng và điều khiển ứng dụng ra khỏi nhau, giúp cho việc phát triển và bảo trì ứng dụng trở nên dễ dàng hơn.
- User
- Assistant
1 00:00:01,740 --> 00:00:08,130 Định nghĩa đầu tiên và viết tắt cho mô hình hướng Mẫu - Xem - Điều khiển.
2 00:00:08,730 --> 00:00:14,220 Nhưng các khái niệm này là gì và chúng có liên quan như thế nào với nhau?
3 00:00:14,940 --> 00:00:21,840 Một mô hình là chỉ một lớp C# đại diện cho một bảng trong cơ sở dữ liệu, trong trường h