Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0613· OpenAIAi2 WildChat-4.8M (AI2)

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

  1. 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.

    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. dịch tiếng việt

  2. Assistant

    1 00:00:01,740 --> 00:00:08,130

    Định nghĩa đầu tiên và viết tắt của "model view controller".

    2 00:00:08,730 --> 00:00:14,220

    Nhưng những khái niệm này là gì và chúng có liên quan như thế nào đến nhau?

    3 00:00:14,940 --> 00:00:21,840

    Một mô hình chỉ là một lớp C# đại diện cho một bảng trong cơ sở dữ liệu trong trường hợp này.

    4 00:00:22,260 --> 00:00:28,950

    Vì vậy, cơ bản nó phục vụ như một bản thiết kế dữ liệu và cũng có thể được sử dụng để xác định các quan hệ dữ liệu.

    5 00:00:29,700 --> 00:00:36,120

    Vì vậy, ví dụ, trong ứng dụng của chúng ta, chúng ta có những nhà sản xuất, chúng ta có những bộ phim, chúng ta có những diễn viên, vv. Bây giờ để lưu trữ

    6 00:00:36,120 --> 00:00:40,770

    Tất cả dữ liệu này trong cơ sở dữ liệu của chúng ta, chúng ta cần tạo bảng và để tạo bảng.

    7 00:00:40,770 --> 00:00:42,840

    Chúng tôi sẽ tạo các mô hình.

    8 00:00:43,080 --> 00:00:48,600

    Vì vậy, ví dụ, chúng tôi sẽ có nhà sản xuất, mô hình diễn viên, vv.

    9 00:00:49,790 --> 00:00:53,720

    Một view, như tên đã chỉ ra, là những gì người dùng được thấy.

    10 00:00:54,020 --> 00:00:58,340

    Vì vậy, đó là một tệp đại diện cho giao diện người dùng.

    11 00:00:58,640 --> 00:01:01,010

    Và một view trong MVC là một C#.

    12 00:01:01,060 --> 00:01:03,530

    Sharp HTML, trong đó C#.

    13 00:01:03,530 --> 00:01:09,440

    S đại diện cho C Sharp và HD ammo cho mã HTML.

    14 00:01:09,860 --> 00:01:18,260

    Vì vậy, các tệp C# HTML hoặc razor views, như chúng tôi gọi chúng, chỉ là sự kết hợp của C#.

    15 00:01:18,590 --> 00:01:21,150

    Và mã HTML từ View.

    16 00:01:21,170 --> 00:01:27,740

    Bạn có thể kích hoạt yêu cầu hoặc các sự kiện được xử lý bởi các controller.

    17 00:01:28,190 --> 00:01:34,310

    Bây giờ, một controller sẽ nhận các sự kiện, sau đó sẽ chuẩn bị một phản hồi và sau đó chỉ trả về

    18 00:01:34,310 --> 00:01:35,930

    phản hồi cho view.

    19 00:01:36,440 --> 00:01:42,110

    Một controller chỉ là một lớp C# kế thừa từ lớp cơ sở controller.

    20 00:01:42,620 --> 00:01:49,460

    Trong suốt khóa học này, bạn sẽ tạo các controller producer, movie, actor, vv. Nhưng làm thế nào các view, models và controllers có liên quan đến nhau bây giờ để hiểu rõ hơn

    21 00:01:49,970 --> 00:01:57,650

    MVC?

    22 00:01:57,650 --> 00:01:58,230

    Hãy tưởng tượng làm ví dụ một ứng dụng Web.

    23 00:01:58,250 --> 00:02:01,040

    Bây giờ, trong một ứng dụng Web, bạn có trình duyệt, bạn có máy chủ và cơ sở dữ liệu.

    24 00:02:01,790 --> 00:02:07,490

    Cách các thành phần này làm việc với nhau là bạn gửi yêu cầu từ trình duyệt.

    25 00:02:08,330 --> 00:02:12,110

    Bạn gửi nó từ trình duyệt đến máy chủ.

    26 00:02:12,200 --> 00:02:14,510

    Sau đó, máy chủ sẽ thu thập dữ liệu từ cơ sở dữ liệu.

    27 00:02:15,200 --> 00:02:18,410

    Và khi dữ liệu sẵn sàng, máy chủ này sẽ trả về dữ liệu cho trình duyệt cùng cách trong MVC.

    28 00:02:18,860 --> 00:02:27,230

    Bây giờ, thay vì một trình duyệt, bạn có một view.

  3. User

    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.

  4. Assistant

    34 00:02:49,660 --> 00:02:55,180

    Sau đó, controller sẽ nhận yêu cầu dựa trên các tham số hoặc không có tham số nào.

    35 00:02:55,420 --> 00:03:00,730

    Chúng ta sẽ xây dựng một phản hồi bằng cách lấy dữ liệu từ cơ sở dữ liệu bằng cách sử dụng các model.

    36 00:03:01,270 --> 00:03:06,160

    Và khi phản hồi đã sẵn sàng, phản hồi sẽ được trả về cho View.

    37 00:03:07,380 --> 00:03:10,020

    Vì vậy, chúng ta hãy xem qua EP mà chúng ta sẽ xây dựng.

    38 00:03:10,650 --> 00:03:16,260

    Vì vậy, khi bạn nhìn vào đây là The View song ở đây chúng ta có, ví dụ, trong EP của chúng ta, chúng ta có một view

    39 00:03:16,290 --> 00:03:18,390

    được sử dụng để hiển thị tất cả các bộ phim.

    40 00:03:18,690 --> 00:03:24,630

    Nhưng nếu bạn đi đến, ví dụ, chi tiết show, đây là một view khác được sử dụng để trả về dữ liệu.

    41 00:03:24,780 --> 00:03:29,670

    Vì vậy, cơ bản là khi bạn đang ở trang danh sách các bộ phim và sau đó nhấp vào đây, chi tiết show.

    42 00:03:30,060 --> 00:03:33,000

    Vì vậy, tôi đang gửi một yêu cầu đến một controller.

    43 00:03:33,600 --> 00:03:35,220

    Controller sẽ nhận yêu cầu.

    44 00:03:35,250 --> 00:03:40,190

    Vì vậy, trong trường hợp này, là home controller details action result?

    45 00:03:40,200 --> 00:03:47,010

    Và nếu có tham số ID là số ba, nó sẽ nhận một số dữ liệu từ cơ sở dữ liệu bằng cách sử dụng các model,

    46 00:03:47,020 --> 00:03:48,090

    các model cần thiết.

    47 00:03:48,630 --> 00:03:51,570

    Và sau đó trả về phản hồi cho view.

    48 00:03:51,930 --> 00:03:57,180

    Vì vậy, cơ bản bạn có một controller sẽ nhận một yêu cầu từ view, sử dụng các model để lấy một số

    49 00:03:57,180 --> 00:04:02,820

    dữ liệu từ cơ sở dữ liệu và sau đó trả về một view khác, hoặc có thể là cùng một view với một số dữ liệu.