Bài 1: Giới thiệu về Trình quản lý quảng cáo

🎓 Bài giảng: Phân tích yêu cầu chức năng và định hình project Website quản lý khóa học


1️⃣ Giới thiệu

Khi bắt đầu xây dựng một phần mềm web, đặc biệt là dạng quản lý khóa học online, chúng ta cần thực hiện bước đầu tiên rất quan trọng, đó là:

👉 Phân tích yêu cầu chức năng

Mục tiêu:

  • Hiểu rõ hệ thống cần làm gì.

  • Phân chia module (area) hợp lý.

  • Xác định controller, action cần thiết.

  • Đảm bảo khi code sẽ dễ mở rộng, bảo trì.


2️⃣ Phân tích yêu cầu theo nhóm chức năng

Hình ảnh bảng phân tích chức năng

3️⃣ Từ yêu cầu đến thiết kế hệ thống

🏗️ Tách area (module lớn)

ASP.NET MVC hỗ trợ Area để chia nhỏ ứng dụng.
Với bài này ta nên chia:

Area Mục đích
(Mặc định) Giao diện người dùng (học viên)
Admin Quản lý hệ thống (user, khóa học, video, admin)

📚 Xác định Controller & Action

💻 1. Phần Học viên (ngoài admin)

Controller Action Mục đích
AccountController Register, Login, Logout, ForgotPassword, Profile Đăng ký, đăng nhập, quên mật khẩu, profile
CourseController Index, Details, WatchVideo Xem danh sách, chi tiết khoá học, xem video

🛠 2. Admin Area

(Trong thư mục Areas/Admin/Controllers)

Controller Action Mục đích
AccountController Login, Logout Đăng nhập admin
UserController Index, Delete, ResetPassword Quản lý user học viên
CourseController Index, Create, Edit, Delete Quản lý khóa học
VideoController Index, Create, Edit, Delete Quản lý video trong khóa học
AdminAccountController Index, Create, Edit, Delete, AssignRole Quản lý admin / phân quyền

🔥 Phân quyền trong admin

  • Trong database AdminAccount sẽ có field Role (SuperAdmin / Staff).

  • Ở các action controller sẽ kiểm tra quyền để cho phép (authorize).

Ví dụ:

[Authorize(Roles="SuperAdmin")]
public ActionResult AssignRole(int adminId) 
{
    // Chỉ super admin mới cấp quyền cho admin khác
}

4️⃣ Kết luận: Chuẩn bị project

📂 Khi tạo project, bạn sẽ có:

  • Areas:

    • Admin (chứa toàn bộ quản lý)

  • Controllers:

    • AccountController, CourseController (ở ngoài)

  • Views:

    • Theo từng controller.

  • Models:

    • User, AdminAccount, Course, Video

  • Shared:

    • _Layout.cshtml, _AdminLayout.cshtml


✅ Tổng kết area, controller, action cần tạo

Area Controller Action
(default) AccountController Register, Login, Logout, ForgotPassword, Profile
(default) CourseController Index, Details, WatchVideo
Admin AccountController Login, Logout
Admin UserController Index, Delete, ResetPassword
Admin CourseController Index, Create, Edit, Delete
Admin VideoController Index, Create, Edit, Delete
Admin AdminAccountController Index, Create, Edit, Delete, AssignRole
 
 

Bài tập số 5: WebDaoTao

Yêu cầu:

  • Thực hành lại với nội dung đã học

  • Tạo đầy đủ controlle và action theo bản phân tích (không làm admin)

Nộp bài:

  • Nén project đã làm và nộp file.