- Học kỳ
- SU2026
- Thời Gian
- 7/8/26
- Loại tài liệu
- PE
PRN232 SU26 PE RE NO5
PRN232 SU26 PE RE NO5
This document contains instructions and requirements for a .NET 8 and Entity Framework Core practical examination, paper number 5. It outlines database configuration guidelines, submission procedures, and specific API implementation tasks including GET, POST, and DELETE endpoints for a gym management system.PRN232 SU26 PE RE NO5
Paper No: 5
INSTRUCTIONS
Please read the instructions carefully before doing the questions.
- You can use materials in your computer, notebook and text book.
- You are NOT allowed to use any device to share data with others.
Beside the above conditions, students must follow the following requirements:
1. The work must complete by using Visual Studio 2022++
2. The Framework must be .NET 8.0
3. THIS PART IS VERY IMPORTANT, PLEASE READ IT CAREFULLY AND FOLLOW THE INSTRUCTIONS.
- You are given a database script (.sql file) in Zip file. Execute the script before doing questions.
- You must use the given solution.
- You are not allowed to add any more libraries via NuGet Package Manager into given solution.
- Submission Guideline:
Submit your work for each question separately. For each question, please:
- Publish your project using the command:
dotnet publish -c Release -o ./[QuestionNumber_StudentAccount]
Example:
dotnet publish -c Release -o ./Q1_trungnthe123432
- Submit the root folder of the project into the PEA_Client application.
- If the root folder of the project is too large, you may delete the following subfolders to reduce its size before submitting: /bin, /obj
Just one of above requirements is violated, your work will be considered as invalid.
Question 1:
You are provided with a database as following diagram
Ensure that the database connection string is adjustable through appsettings.json (otherwise your post will get 0 point) as pattern:
{
"ConnectionStrings":
{
"MyCnn":""
}
}
Your task is to implement the following APIs using .NET 8 and Entity Framework Core:
Method | URL | Description
GET | /api/Specializations | Retrieve all fitness specializations with trainer count statistics. Supports JSON.
GET | /api/filter-trainers | Advanced search for trainers with booking duration stats and recent trainee trace logs.
POST | /api/trainers | Add a new gym trainer to the database.
DELETE | /api/trainers/{trainerId} | Remove a trainer and clear their spec links.
1. GET /api/Specializations
- Retrieve a list of all fitness specializations from the database.
- Response Fields:
specId (int)
specName (string)
description (string)
TrainerCount (int): Total number of trainers holding this specialization.
2. GET /api/filter-trainers
Retrieve a list of gym trainers with advanced booking performance statistics.
- Filtering Logic:
specId (int, optional): If specified, return only trainers associated with this Specialization ID.
minExperience (int, optional): If specified, return only trainers whose experience (years) is greater than or equal to this value.
- Response Fields:
TrainerId, TrainerName, Email, ExperienceYears.
TotalMinutesTrained (int): The total sum of DurationMinutes conducted by this trainer across all booking sessions in the BookingDetails table. Return 0 if there are no sessions.
LastBookedMember (string): The FullName of the gym member who booked a session with this trainer most recently (based on Bookings.SessionTime descending). If no sessions are booked, return "No Bookings".
SpecializationList (List of string): A collection of SpecName categories this trainer specializes in.
- Error handling: Return 400 Bad Request if minExperience is negative (if provided).
- Sorting: Sort results by ExperienceYears in descending order.
3. POST /api/trainers
Accept TrainerName, Email, and ExperienceYears inside the request body.
- Return: 201 Created along with the complete newly created Trainer entity (ensure navigation properties like Bookings and Specs / Specializations are returned as empty lists [] instead of null to avoid client integration crashes).
- Error handling: If the trainer's Email already exists (case-insensitive check), return 400 Bad Request with message "Trainer email already exists".
Đính kèm
-
PRN232 SU26 PE RE NO5_001.webp131.9 KB · Lượt xem: 48 -
PRN232 SU26 PE RE NO5_002.webp105.4 KB · Lượt xem: 48 -
PRN232 SU26 PE RE NO5_003.webp88.5 KB · Lượt xem: 44 -
PRN232 SU26 PE RE NO5_004.webp125.7 KB · Lượt xem: 43 -
PRN232 SU26 PE RE NO5_005.webp90 KB · Lượt xem: 44 -
PRN232 SU26 PE RE NO5_006.webp43.2 KB · Lượt xem: 37 -
PRN232 SU26 PE RE NO5_007.webp81.3 KB · Lượt xem: 31 -
PRN232 SU26 PE RE NO5_008.webp95.5 KB · Lượt xem: 32 -
PRN232 SU26 PE RE NO5_009.webp135.4 KB · Lượt xem: 27 -
PRN232 SU26 PE RE NO5_010.webp95.4 KB · Lượt xem: 28 -
PRN232 SU26 PE RE NO5_011.webp127.8 KB · Lượt xem: 22 -
PRN232 SU26 PE RE NO5_012.webp99.6 KB · Lượt xem: 21 -
PRN232 SU26 PE RE NO5_013.webp42.3 KB · Lượt xem: 19 -
PRN232 SU26 PE RE NO5_014.webp115.7 KB · Lượt xem: 30
Sửa lần cuối:


