From cb0a3a8b5ccc5e41963bc4ddfd99ad61eef49cf0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 19 Nov 2025 11:05:04 +0000 Subject: [PATCH 1/2] Initial plan From 7ef459c246ed599ab29490e0020afdb7efd02169 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 19 Nov 2025 11:13:56 +0000 Subject: [PATCH 2/2] Replace single-letter lambda parameters with descriptive names Co-authored-by: Hemavathi15sg <224925058+Hemavathi15sg@users.noreply.github.com> --- .../Services/CertificateService.cs | 18 ++-- .../Services/CourseService.cs | 4 +- .../Services/StudentService.cs | 2 +- .../Entities/Course.cs | 2 +- .../Data/CourseRegistrationDbContext.cs | 82 +++++++++---------- .../Repositories/CourseRepository.cs | 44 +++++----- .../Repositories/RegistrationRepository.cs | 62 +++++++------- .../Repositories/StudentRepository.cs | 40 ++++----- 8 files changed, 127 insertions(+), 127 deletions(-) diff --git a/api/CourseRegistration.Application/Services/CertificateService.cs b/api/CourseRegistration.Application/Services/CertificateService.cs index 01e20a5..0dfd97e 100644 --- a/api/CourseRegistration.Application/Services/CertificateService.cs +++ b/api/CourseRegistration.Application/Services/CertificateService.cs @@ -91,7 +91,7 @@ public async Task> GetCertificatesByStudentIdAsync(G { await Task.CompletedTask; // Simulate async operation - var certificates = _certificates.Where(c => c.StudentId == studentId); + var certificates = _certificates.Where(certificate => certificate.StudentId == studentId); return certificates.Select(MapToDto); } @@ -99,7 +99,7 @@ public async Task> GetCertificatesByStudentIdAsync(G { await Task.CompletedTask; // Simulate async operation - var certificate = _certificates.FirstOrDefault(c => c.CertificateId == certificateId); + var certificate = _certificates.FirstOrDefault(cert => cert.CertificateId == certificateId); return certificate != null ? MapToDto(certificate) : null; } @@ -107,15 +107,15 @@ public async Task> GetCertificatesByStudentNameAsync { await Task.CompletedTask; // Simulate async operation - var matchingStudents = _students.Where(s => - $"{s.FirstName} {s.LastName}".Contains(studentName, StringComparison.OrdinalIgnoreCase) || - s.FirstName.Contains(studentName, StringComparison.OrdinalIgnoreCase) || - s.LastName.Contains(studentName, StringComparison.OrdinalIgnoreCase)); + var matchingStudents = _students.Where(student => + $"{student.FirstName} {student.LastName}".Contains(studentName, StringComparison.OrdinalIgnoreCase) || + student.FirstName.Contains(studentName, StringComparison.OrdinalIgnoreCase) || + student.LastName.Contains(studentName, StringComparison.OrdinalIgnoreCase)); var certificates = new List(); foreach (var student in matchingStudents) { - certificates.AddRange(_certificates.Where(c => c.StudentId == student.StudentId)); + certificates.AddRange(_certificates.Where(certificate => certificate.StudentId == student.StudentId)); } return certificates.Select(MapToDto); @@ -150,8 +150,8 @@ public string GenerateCertificateNumber() private CertificateDto MapToDto(Certificate certificate) { - var student = _students.FirstOrDefault(s => s.StudentId == certificate.StudentId); - var course = _courses.FirstOrDefault(c => c.CourseId == certificate.CourseId); + var student = _students.FirstOrDefault(stud => stud.StudentId == certificate.StudentId); + var course = _courses.FirstOrDefault(crs => crs.CourseId == certificate.CourseId); return new CertificateDto { diff --git a/api/CourseRegistration.Application/Services/CourseService.cs b/api/CourseRegistration.Application/Services/CourseService.cs index 81844b0..914d8a6 100644 --- a/api/CourseRegistration.Application/Services/CourseService.cs +++ b/api/CourseRegistration.Application/Services/CourseService.cs @@ -44,7 +44,7 @@ public async Task> GetCoursesAsync(int page = 1, int else { courses = await _unitOfWork.Courses.GetPagedAsync(page, pageSize); - totalCourses = await _unitOfWork.Courses.CountAsync(c => ((Course)c).IsActive); + totalCourses = await _unitOfWork.Courses.CountAsync(course => ((Course)course).IsActive); } var courseDtos = _mapper.Map>(courses); @@ -129,7 +129,7 @@ public async Task DeleteCourseAsync(Guid id) // Check if course has active registrations var activeRegistrations = await _unitOfWork.Registrations.GetByCourseIdAsync(id); - if (activeRegistrations.Any(r => r.Status == Domain.Enums.RegistrationStatus.Confirmed)) + if (activeRegistrations.Any(registration => registration.Status == Domain.Enums.RegistrationStatus.Confirmed)) { throw new InvalidOperationException("Cannot delete a course with active registrations."); } diff --git a/api/CourseRegistration.Application/Services/StudentService.cs b/api/CourseRegistration.Application/Services/StudentService.cs index dc1aeb8..dfeb138 100644 --- a/api/CourseRegistration.Application/Services/StudentService.cs +++ b/api/CourseRegistration.Application/Services/StudentService.cs @@ -33,7 +33,7 @@ public async Task> GetStudentsAsync(int page = 1, i if (pageSize > 100) pageSize = 100; var students = await _unitOfWork.Students.GetPagedAsync(page, pageSize); - var totalStudents = await _unitOfWork.Students.CountAsync(s => ((Student)s).IsActive); + var totalStudents = await _unitOfWork.Students.CountAsync(student => ((Student)student).IsActive); var studentDtos = _mapper.Map>(students); diff --git a/api/CourseRegistration.Domain/Entities/Course.cs b/api/CourseRegistration.Domain/Entities/Course.cs index dc3f941..500a4ce 100644 --- a/api/CourseRegistration.Domain/Entities/Course.cs +++ b/api/CourseRegistration.Domain/Entities/Course.cs @@ -77,5 +77,5 @@ public class Course /// Computed property for current enrollment count /// [NotMapped] - public int CurrentEnrollment => Registrations?.Count(r => r.Status == Enums.RegistrationStatus.Confirmed) ?? 0; + public int CurrentEnrollment => Registrations?.Count(registration => registration.Status == Enums.RegistrationStatus.Confirmed) ?? 0; } \ No newline at end of file diff --git a/api/CourseRegistration.Infrastructure/Data/CourseRegistrationDbContext.cs b/api/CourseRegistration.Infrastructure/Data/CourseRegistrationDbContext.cs index 7491da8..04ce618 100644 --- a/api/CourseRegistration.Infrastructure/Data/CourseRegistrationDbContext.cs +++ b/api/CourseRegistration.Infrastructure/Data/CourseRegistrationDbContext.cs @@ -42,70 +42,70 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) // Configure Student entity modelBuilder.Entity(entity => { - entity.HasKey(s => s.StudentId); - entity.HasIndex(s => s.Email).IsUnique(); - entity.Property(s => s.FirstName).IsRequired().HasMaxLength(50); - entity.Property(s => s.LastName).IsRequired().HasMaxLength(50); - entity.Property(s => s.Email).IsRequired().HasMaxLength(256); - entity.Property(s => s.PhoneNumber).HasMaxLength(20); - entity.Property(s => s.DateOfBirth).IsRequired(); - entity.Property(s => s.CreatedAt).IsRequired(); - entity.Property(s => s.UpdatedAt).IsRequired(); - entity.Property(s => s.IsActive).IsRequired(); + entity.HasKey(student => student.StudentId); + entity.HasIndex(student => student.Email).IsUnique(); + entity.Property(student => student.FirstName).IsRequired().HasMaxLength(50); + entity.Property(student => student.LastName).IsRequired().HasMaxLength(50); + entity.Property(student => student.Email).IsRequired().HasMaxLength(256); + entity.Property(student => student.PhoneNumber).HasMaxLength(20); + entity.Property(student => student.DateOfBirth).IsRequired(); + entity.Property(student => student.CreatedAt).IsRequired(); + entity.Property(student => student.UpdatedAt).IsRequired(); + entity.Property(student => student.IsActive).IsRequired(); // Configure relationships - entity.HasMany(s => s.Registrations) - .WithOne(r => r.Student) - .HasForeignKey(r => r.StudentId) + entity.HasMany(student => student.Registrations) + .WithOne(registration => registration.Student) + .HasForeignKey(registration => registration.StudentId) .OnDelete(DeleteBehavior.Cascade); }); // Configure Course entity modelBuilder.Entity(entity => { - entity.HasKey(c => c.CourseId); - entity.Property(c => c.CourseName).IsRequired().HasMaxLength(100); - entity.Property(c => c.Description).HasMaxLength(500); - entity.Property(c => c.InstructorName).IsRequired().HasMaxLength(100); - entity.Property(c => c.StartDate).IsRequired(); - entity.Property(c => c.EndDate).IsRequired(); - entity.Property(c => c.Schedule).IsRequired().HasMaxLength(100); - entity.Property(c => c.IsActive).IsRequired(); - entity.Property(c => c.CreatedAt).IsRequired(); - entity.Property(c => c.UpdatedAt).IsRequired(); + entity.HasKey(course => course.CourseId); + entity.Property(course => course.CourseName).IsRequired().HasMaxLength(100); + entity.Property(course => course.Description).HasMaxLength(500); + entity.Property(course => course.InstructorName).IsRequired().HasMaxLength(100); + entity.Property(course => course.StartDate).IsRequired(); + entity.Property(course => course.EndDate).IsRequired(); + entity.Property(course => course.Schedule).IsRequired().HasMaxLength(100); + entity.Property(course => course.IsActive).IsRequired(); + entity.Property(course => course.CreatedAt).IsRequired(); + entity.Property(course => course.UpdatedAt).IsRequired(); // Configure relationships - entity.HasMany(c => c.Registrations) - .WithOne(r => r.Course) - .HasForeignKey(r => r.CourseId) + entity.HasMany(course => course.Registrations) + .WithOne(registration => registration.Course) + .HasForeignKey(registration => registration.CourseId) .OnDelete(DeleteBehavior.Cascade); }); // Configure Registration entity modelBuilder.Entity(entity => { - entity.HasKey(r => r.RegistrationId); - entity.Property(r => r.StudentId).IsRequired(); - entity.Property(r => r.CourseId).IsRequired(); - entity.Property(r => r.RegistrationDate).IsRequired(); - entity.Property(r => r.Status).IsRequired() + entity.HasKey(registration => registration.RegistrationId); + entity.Property(registration => registration.StudentId).IsRequired(); + entity.Property(registration => registration.CourseId).IsRequired(); + entity.Property(registration => registration.RegistrationDate).IsRequired(); + entity.Property(registration => registration.Status).IsRequired() .HasConversion(); - entity.Property(r => r.Grade).HasConversion(); - entity.Property(r => r.Notes).HasMaxLength(200); + entity.Property(registration => registration.Grade).HasConversion(); + entity.Property(registration => registration.Notes).HasMaxLength(200); // Create unique constraint to prevent duplicate registrations - entity.HasIndex(r => new { r.StudentId, r.CourseId }) + entity.HasIndex(registration => new { registration.StudentId, registration.CourseId }) .IsUnique(); // Configure relationships - entity.HasOne(r => r.Student) - .WithMany(s => s.Registrations) - .HasForeignKey(r => r.StudentId) + entity.HasOne(registration => registration.Student) + .WithMany(student => student.Registrations) + .HasForeignKey(registration => registration.StudentId) .OnDelete(DeleteBehavior.Cascade); - entity.HasOne(r => r.Course) - .WithMany(c => c.Registrations) - .HasForeignKey(r => r.CourseId) + entity.HasOne(registration => registration.Course) + .WithMany(course => course.Registrations) + .HasForeignKey(registration => registration.CourseId) .OnDelete(DeleteBehavior.Cascade); }); } @@ -134,7 +134,7 @@ public override async Task SaveChangesAsync(CancellationToken cancellationT private void UpdateTimestamps() { var entries = ChangeTracker.Entries() - .Where(e => e.State == EntityState.Added || e.State == EntityState.Modified); + .Where(entry => entry.State == EntityState.Added || entry.State == EntityState.Modified); var currentTime = DateTime.UtcNow; diff --git a/api/CourseRegistration.Infrastructure/Repositories/CourseRepository.cs b/api/CourseRegistration.Infrastructure/Repositories/CourseRepository.cs index 985a879..cd17e30 100644 --- a/api/CourseRegistration.Infrastructure/Repositories/CourseRepository.cs +++ b/api/CourseRegistration.Infrastructure/Repositories/CourseRepository.cs @@ -24,10 +24,10 @@ public CourseRepository(CourseRegistrationDbContext context) : base(context) public async Task GetWithRegistrationsAsync(Guid courseId) { return await _dbSet - .Include(c => c.Registrations) - .ThenInclude(r => r.Student) - .Where(c => c.IsActive) - .FirstOrDefaultAsync(c => c.CourseId == courseId); + .Include(course => course.Registrations) + .ThenInclude(registration => registration.Student) + .Where(course => course.IsActive) + .FirstOrDefaultAsync(course => course.CourseId == courseId); } /// @@ -35,24 +35,24 @@ public CourseRepository(CourseRegistrationDbContext context) : base(context) /// public async Task> SearchCoursesAsync(string? searchTerm, string? instructor) { - var query = _dbSet.Where(c => c.IsActive); + var query = _dbSet.Where(course => course.IsActive); if (!string.IsNullOrWhiteSpace(searchTerm)) { var lowerSearchTerm = searchTerm.ToLower(); - query = query.Where(c => - c.CourseName.ToLower().Contains(lowerSearchTerm) || - (c.Description != null && c.Description.ToLower().Contains(lowerSearchTerm))); + query = query.Where(course => + course.CourseName.ToLower().Contains(lowerSearchTerm) || + (course.Description != null && course.Description.ToLower().Contains(lowerSearchTerm))); } if (!string.IsNullOrWhiteSpace(instructor)) { var lowerInstructor = instructor.ToLower(); - query = query.Where(c => c.InstructorName.ToLower().Contains(lowerInstructor)); + query = query.Where(course => course.InstructorName.ToLower().Contains(lowerInstructor)); } return await query - .OrderBy(c => c.CourseName) + .OrderBy(course => course.CourseName) .ToListAsync(); } @@ -62,8 +62,8 @@ public async Task> SearchCoursesAsync(string? searchTerm, st public async Task> GetActiveCoursesAsync() { return await _dbSet - .Where(c => c.IsActive) - .OrderBy(c => c.CourseName) + .Where(course => course.IsActive) + .OrderBy(course => course.CourseName) .ToListAsync(); } @@ -75,10 +75,10 @@ public async Task> GetAvailableCoursesAsync() var currentDate = DateTime.UtcNow; return await _dbSet - .Include(c => c.Registrations) - .Where(c => c.IsActive && c.StartDate > currentDate) - .OrderBy(c => c.StartDate) - .ThenBy(c => c.CourseName) + .Include(course => course.Registrations) + .Where(course => course.IsActive && course.StartDate > currentDate) + .OrderBy(course => course.StartDate) + .ThenBy(course => course.CourseName) .ToListAsync(); } @@ -92,8 +92,8 @@ public async Task> GetCoursesByInstructorAsync(string instru var lowerInstructorName = instructorName.ToLower(); return await _dbSet - .Where(c => c.IsActive && c.InstructorName.ToLower().Contains(lowerInstructorName)) - .OrderBy(c => c.CourseName) + .Where(course => course.IsActive && course.InstructorName.ToLower().Contains(lowerInstructorName)) + .OrderBy(course => course.CourseName) .ToListAsync(); } @@ -107,8 +107,8 @@ public override async Task> GetPagedAsync(int page, int page if (pageSize > 100) pageSize = 100; return await _dbSet - .Where(c => c.IsActive) - .OrderBy(c => c.CourseName) + .Where(course => course.IsActive) + .OrderBy(course => course.CourseName) .Skip((page - 1) * pageSize) .Take(pageSize) .ToListAsync(); @@ -120,8 +120,8 @@ public override async Task> GetPagedAsync(int page, int page public override async Task GetByIdAsync(Guid id) { return await _dbSet - .Where(c => c.IsActive) - .FirstOrDefaultAsync(c => c.CourseId == id); + .Where(course => course.IsActive) + .FirstOrDefaultAsync(course => course.CourseId == id); } /// diff --git a/api/CourseRegistration.Infrastructure/Repositories/RegistrationRepository.cs b/api/CourseRegistration.Infrastructure/Repositories/RegistrationRepository.cs index 9320de1..dc40f6f 100644 --- a/api/CourseRegistration.Infrastructure/Repositories/RegistrationRepository.cs +++ b/api/CourseRegistration.Infrastructure/Repositories/RegistrationRepository.cs @@ -25,10 +25,10 @@ public RegistrationRepository(CourseRegistrationDbContext context) : base(contex public async Task> GetByStudentIdAsync(Guid studentId) { return await _dbSet - .Include(r => r.Course) - .Include(r => r.Student) - .Where(r => r.StudentId == studentId) - .OrderByDescending(r => r.RegistrationDate) + .Include(registration => registration.Course) + .Include(registration => registration.Student) + .Where(registration => registration.StudentId == studentId) + .OrderByDescending(registration => registration.RegistrationDate) .ToListAsync(); } @@ -38,11 +38,11 @@ public async Task> GetByStudentIdAsync(Guid studentId) public async Task> GetByCourseIdAsync(Guid courseId) { return await _dbSet - .Include(r => r.Student) - .Include(r => r.Course) - .Where(r => r.CourseId == courseId) - .OrderBy(r => r.Student.LastName) - .ThenBy(r => r.Student.FirstName) + .Include(registration => registration.Student) + .Include(registration => registration.Course) + .Where(registration => registration.CourseId == courseId) + .OrderBy(registration => registration.Student.LastName) + .ThenBy(registration => registration.Student.FirstName) .ToListAsync(); } @@ -52,10 +52,10 @@ public async Task> GetByCourseIdAsync(Guid courseId) public async Task> GetByStatusAsync(RegistrationStatus status) { return await _dbSet - .Include(r => r.Student) - .Include(r => r.Course) - .Where(r => r.Status == status) - .OrderByDescending(r => r.RegistrationDate) + .Include(registration => registration.Student) + .Include(registration => registration.Course) + .Where(registration => registration.Status == status) + .OrderByDescending(registration => registration.RegistrationDate) .ToListAsync(); } @@ -65,9 +65,9 @@ public async Task> GetByStatusAsync(RegistrationStatus public async Task IsStudentRegisteredForCourseAsync(Guid studentId, Guid courseId) { return await _dbSet - .AnyAsync(r => r.StudentId == studentId && - r.CourseId == courseId && - r.Status != RegistrationStatus.Cancelled); + .AnyAsync(registration => registration.StudentId == studentId && + registration.CourseId == courseId && + registration.Status != RegistrationStatus.Cancelled); } /// @@ -76,9 +76,9 @@ public async Task IsStudentRegisteredForCourseAsync(Guid studentId, Guid c public async Task GetWithDetailsAsync(Guid registrationId) { return await _dbSet - .Include(r => r.Student) - .Include(r => r.Course) - .FirstOrDefaultAsync(r => r.RegistrationId == registrationId); + .Include(registration => registration.Student) + .Include(registration => registration.Course) + .FirstOrDefaultAsync(registration => registration.RegistrationId == registrationId); } /// @@ -90,27 +90,27 @@ public async Task> GetRegistrationsWithFiltersAsync( RegistrationStatus? status = null) { var query = _dbSet - .Include(r => r.Student) - .Include(r => r.Course) + .Include(registration => registration.Student) + .Include(registration => registration.Course) .AsQueryable(); if (studentId.HasValue) { - query = query.Where(r => r.StudentId == studentId.Value); + query = query.Where(registration => registration.StudentId == studentId.Value); } if (courseId.HasValue) { - query = query.Where(r => r.CourseId == courseId.Value); + query = query.Where(registration => registration.CourseId == courseId.Value); } if (status.HasValue) { - query = query.Where(r => r.Status == status.Value); + query = query.Where(registration => registration.Status == status.Value); } return await query - .OrderByDescending(r => r.RegistrationDate) + .OrderByDescending(registration => registration.RegistrationDate) .ToListAsync(); } @@ -124,9 +124,9 @@ public override async Task> GetPagedAsync(int page, in if (pageSize > 100) pageSize = 100; return await _dbSet - .Include(r => r.Student) - .Include(r => r.Course) - .OrderByDescending(r => r.RegistrationDate) + .Include(registration => registration.Student) + .Include(registration => registration.Course) + .OrderByDescending(registration => registration.RegistrationDate) .Skip((page - 1) * pageSize) .Take(pageSize) .ToListAsync(); @@ -138,8 +138,8 @@ public override async Task> GetPagedAsync(int page, in public override async Task GetByIdAsync(Guid id) { return await _dbSet - .Include(r => r.Student) - .Include(r => r.Course) - .FirstOrDefaultAsync(r => r.RegistrationId == id); + .Include(registration => registration.Student) + .Include(registration => registration.Course) + .FirstOrDefaultAsync(registration => registration.RegistrationId == id); } } \ No newline at end of file diff --git a/api/CourseRegistration.Infrastructure/Repositories/StudentRepository.cs b/api/CourseRegistration.Infrastructure/Repositories/StudentRepository.cs index 7f03bab..8898f25 100644 --- a/api/CourseRegistration.Infrastructure/Repositories/StudentRepository.cs +++ b/api/CourseRegistration.Infrastructure/Repositories/StudentRepository.cs @@ -24,8 +24,8 @@ public StudentRepository(CourseRegistrationDbContext context) : base(context) public async Task GetByEmailAsync(string email) { return await _dbSet - .Where(s => s.IsActive) - .FirstOrDefaultAsync(s => s.Email.ToLower() == email.ToLower()); + .Where(student => student.IsActive) + .FirstOrDefaultAsync(student => student.Email.ToLower() == email.ToLower()); } /// @@ -34,10 +34,10 @@ public StudentRepository(CourseRegistrationDbContext context) : base(context) public async Task GetWithRegistrationsAsync(Guid studentId) { return await _dbSet - .Include(s => s.Registrations) - .ThenInclude(r => r.Course) - .Where(s => s.IsActive) - .FirstOrDefaultAsync(s => s.StudentId == studentId); + .Include(student => student.Registrations) + .ThenInclude(registration => registration.Course) + .Where(student => student.IsActive) + .FirstOrDefaultAsync(student => student.StudentId == studentId); } /// @@ -50,12 +50,12 @@ public async Task> SearchByNameAsync(string searchTerm) var lowerSearchTerm = searchTerm.ToLower(); return await _dbSet - .Where(s => s.IsActive && - (s.FirstName.ToLower().Contains(lowerSearchTerm) || - s.LastName.ToLower().Contains(lowerSearchTerm) || - s.Email.ToLower().Contains(lowerSearchTerm))) - .OrderBy(s => s.LastName) - .ThenBy(s => s.FirstName) + .Where(student => student.IsActive && + (student.FirstName.ToLower().Contains(lowerSearchTerm) || + student.LastName.ToLower().Contains(lowerSearchTerm) || + student.Email.ToLower().Contains(lowerSearchTerm))) + .OrderBy(student => student.LastName) + .ThenBy(student => student.FirstName) .ToListAsync(); } @@ -65,9 +65,9 @@ public async Task> SearchByNameAsync(string searchTerm) public async Task> GetActiveStudentsAsync() { return await _dbSet - .Where(s => s.IsActive) - .OrderBy(s => s.LastName) - .ThenBy(s => s.FirstName) + .Where(student => student.IsActive) + .OrderBy(student => student.LastName) + .ThenBy(student => student.FirstName) .ToListAsync(); } @@ -81,9 +81,9 @@ public override async Task> GetPagedAsync(int page, int pag if (pageSize > 100) pageSize = 100; return await _dbSet - .Where(s => s.IsActive) - .OrderBy(s => s.LastName) - .ThenBy(s => s.FirstName) + .Where(student => student.IsActive) + .OrderBy(student => student.LastName) + .ThenBy(student => student.FirstName) .Skip((page - 1) * pageSize) .Take(pageSize) .ToListAsync(); @@ -95,8 +95,8 @@ public override async Task> GetPagedAsync(int page, int pag public override async Task GetByIdAsync(Guid id) { return await _dbSet - .Where(s => s.IsActive) - .FirstOrDefaultAsync(s => s.StudentId == id); + .Where(student => student.IsActive) + .FirstOrDefaultAsync(student => student.StudentId == id); } ///