From 652e93fda07159eb949af8c739b899c35e5d4551 Mon Sep 17 00:00:00 2001 From: ncj <109492180+NiloJr-sun@users.noreply.github.com> Date: Fri, 7 Jul 2023 17:58:14 +0800 Subject: [PATCH] HRIS-335 [BE] Implement fetching of filed schedules on a specific user (#293) --- api/Schema/Queries/EmployeeScheduleQuery.cs | 6 ++++++ api/Services/EmployeeScheduleService.cs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/api/Schema/Queries/EmployeeScheduleQuery.cs b/api/Schema/Queries/EmployeeScheduleQuery.cs index f63fcc4c..00b31f31 100644 --- a/api/Schema/Queries/EmployeeScheduleQuery.cs +++ b/api/Schema/Queries/EmployeeScheduleQuery.cs @@ -1,4 +1,5 @@ using api.DTOs; +using api.Entities; using api.Middlewares.Attributes; using api.Requests; using api.Services; @@ -29,6 +30,11 @@ public async Task> GetEmployeesBySchedule(int employeeScheduleId) return await _employeeScheduleService.GetEmployeesBySchedule(employeeScheduleId); } + public async Task?> GetEmployeeChangeScheduleRequest(int userId) + { + return await _employeeScheduleService.GetEmployeeChangeScheduleRequest(userId); + } + [AdminUser] public async Task> SearchEmployeesBySchedule(SearchEmployeesByScheduleRequest request) { diff --git a/api/Services/EmployeeScheduleService.cs b/api/Services/EmployeeScheduleService.cs index 5feab5e7..c599a72f 100644 --- a/api/Services/EmployeeScheduleService.cs +++ b/api/Services/EmployeeScheduleService.cs @@ -46,6 +46,12 @@ public async Task> GetEmployeeScheduleDetails(int empl .ToListAsync(); } + public async Task?> GetEmployeeChangeScheduleRequest(int userId) + { + using HrisContext context = _contextFactory.CreateDbContext(); + return await context.ChangeScheduleRequests.Where(x => x.UserId == userId).ToListAsync(); + } + public async Task Create(CreateEmployeeScheduleRequest request, HrisContext context) { // validate inputs