Skip to content

Add closure Schedule#12

Open
ThishaniDissanayake wants to merge 2 commits intodevfrom
feature/add-service-center
Open

Add closure Schedule#12
ThishaniDissanayake wants to merge 2 commits intodevfrom
feature/add-service-center

Conversation

@ThishaniDissanayake
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds support for tracking service availability by day and scheduling closures for service centers.

  • Introduces ServiceAvailability and ClosureSchedule models and corresponding DbSet entries.
  • Creates EF Core migrations and updates the model snapshot to include the new tables.
  • Implements API endpoints in ServiceController and ClosureScheduleController for querying and setting availability and closures.

Reviewed Changes

Copilot reviewed 31 out of 57 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Vpassbackend/Models/ServiceAvailability.cs New model for per-day service availability
Vpassbackend/Models/ClosureSchedule.cs New model for service center closure schedule
Vpassbackend/Data/ApplicationDbContext.cs Added DbSet properties for the new models
Vpassbackend/Migrations/* Multiple migrations to create/update the new tables
Vpassbackend/Controllers/ServiceController.cs Endpoints for querying and updating availability
Vpassbackend/Controllers/ClosureScheduleController.cs Endpoints for managing closure schedules
Vpassbackend/appsettings.json Updated database connection string
Files not reviewed (10)
  • Vpassbackend/Migrations/20250709065437_InitialCreate.Designer.cs: Language not supported
  • Vpassbackend/Migrations/20250710153706_AddServiceCenterManagement.Designer.cs: Language not supported
  • Vpassbackend/Migrations/20250710160743_CreateServiceCenterServicesTable.Designer.cs: Language not supported
  • Vpassbackend/Migrations/20250710161221_UpdateAppointmentModel.Designer.cs: Language not supported
  • Vpassbackend/Migrations/20250710161540_UpdateAppointmentRelationships.Designer.cs: Language not supported
  • Vpassbackend/Migrations/20250710190000_AddServiceReminders.Designer.cs: Language not supported
  • Vpassbackend/Migrations/20250711060932_InitialCreate.Designer.cs: Language not supported
  • Vpassbackend/Migrations/20250711072041_AddClosureScheduleAndServiceAvailability.Designer.cs: Language not supported
  • Vpassbackend/Migrations/20250711090724_AddDayToServiceAvailability.Designer.cs: Language not supported
  • Vpassbackend/Migrations/20250711124807_AddServiceAvailabilityAndClosureSchedule.Designer.cs: Language not supported
Comments suppressed due to low confidence (2)

Vpassbackend/Controllers/ClosureScheduleController.cs:17

  • No unit or integration tests were added for this endpoint. Consider adding tests to verify duplicate detection and successful insertion.
        public async Task<IActionResult> AddClosure([FromBody] ClosureSchedule closure)

Vpassbackend/Migrations/20250711072041_AddClosureScheduleAndServiceAvailability.cs:13

  • Both this migration and 20250711124807_AddServiceAvailabilityAndClosureSchedule.cs create the same tables. Consolidate or remove the duplicate migration to avoid conflicts.
            migrationBuilder.CreateTable(

protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ClosureSchedules",
Copy link

Copilot AI Jul 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a foreign key constraint on ServiceCenterId to ServiceCenters and an index on (ServiceCenterId, WeekNumber, Day) for referential integrity and query performance.

Copilot uses AI. Check for mistakes.
Comment on lines +19 to +28
var services = _context.ServiceCenterServices
.Where(s => s.Station_id == serviceCenterId)
.Select(s => new {
s.ServiceId,
s.Service.ServiceName,
IsAvailable = !_context.ServiceAvailabilities.Any(a =>
a.ServiceCenterId == serviceCenterId &&
a.ServiceId == s.ServiceId &&
a.WeekNumber == weekNumber &&
!a.IsAvailable)
Copy link

Copilot AI Jul 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The LINQ .Any(...) subquery inside .Select may generate one correlated subquery per row. Consider loading availability data in a single query or using a join to reduce database round trips.

Suggested change
var services = _context.ServiceCenterServices
.Where(s => s.Station_id == serviceCenterId)
.Select(s => new {
s.ServiceId,
s.Service.ServiceName,
IsAvailable = !_context.ServiceAvailabilities.Any(a =>
a.ServiceCenterId == serviceCenterId &&
a.ServiceId == s.ServiceId &&
a.WeekNumber == weekNumber &&
!a.IsAvailable)
var unavailableServices = _context.ServiceAvailabilities
.Where(a => a.ServiceCenterId == serviceCenterId &&
a.WeekNumber == weekNumber &&
!a.IsAvailable)
.ToList();
var unavailableServiceIds = new HashSet<int>(unavailableServices.Select(a => a.ServiceId));
var services = _context.ServiceCenterServices
.Where(s => s.Station_id == serviceCenterId)
.Select(s => new {
s.ServiceId,
s.Service.ServiceName,
IsAvailable = !unavailableServiceIds.Contains(s.ServiceId)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants