From f7bc7af9e3f4a19edaa9506e3a9e64923fb0999d Mon Sep 17 00:00:00 2001 From: Sergey Karmanov Date: Thu, 26 Mar 2026 02:50:04 +0300 Subject: [PATCH] =?UTF-8?q?feat(employees):=20=D0=94=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D0=BB=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D1=8C=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=D0=B0?= =?UTF-8?q?=20=D1=81=D0=BE=D1=82=D1=80=D1=83=D0=B4=D0=BD=D0=B8=D0=BA=D0=BE?= =?UTF-8?q?=D0=B2=20=D0=BF=D0=BE=20=D0=B8=D0=BC=D0=B5=D0=BD=D0=B8=20=D1=81?= =?UTF-8?q?=20=D1=83=D1=87=D0=B5=D1=82=D0=BE=D0=BC=20=D0=BF=D1=83=D1=81?= =?UTF-8?q?=D1=82=D0=BE=D0=B3=D0=BE=20=D0=B7=D0=BD=D0=B0=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=B8=20=D0=B2=D0=BA=D0=BB=D1=8E=D1=87=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=81=D0=BE=D1=80=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=BA?= =?UTF-8?q?=D1=83=20=D0=BF=D0=BE=20=D1=84=D0=B8=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SfeduSchedule/Controllers/ScheduleController.cs | 3 +-- SfeduSchedule/Services/ModeusEmployeeService.cs | 9 ++++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/SfeduSchedule/Controllers/ScheduleController.cs b/SfeduSchedule/Controllers/ScheduleController.cs index 301a62d..15c1110 100644 --- a/SfeduSchedule/Controllers/ScheduleController.cs +++ b/SfeduSchedule/Controllers/ScheduleController.cs @@ -1,4 +1,3 @@ -using System.ComponentModel.DataAnnotations; using System.Text; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -46,7 +45,7 @@ public class ScheduleController(ModeusService modeusService, ModeusEmployeeServi /// Сервис сотрудников не инициализирован [HttpGet] [Route("searchemployee")] - public async Task SearchEmployees([Required][MinLength(1)] string fullname) + public async Task SearchEmployees(string fullname = "") { if (!modeusEmployeeService.IsInitialized()) return StatusCode(503, "Сервис сотрудников не инициализирован, попробуйте позже."); diff --git a/SfeduSchedule/Services/ModeusEmployeeService.cs b/SfeduSchedule/Services/ModeusEmployeeService.cs index 76bb8a2..34cabdf 100644 --- a/SfeduSchedule/Services/ModeusEmployeeService.cs +++ b/SfeduSchedule/Services/ModeusEmployeeService.cs @@ -6,15 +6,22 @@ namespace SfeduSchedule.Services; public class ModeusEmployeeService(ISchedulerFactory schedulerFactory) : IHostedService { - private Dictionary)> _employees = []; + private Dictionary)> _employees = []; // private Task? _backgroundTask; private CancellationTokenSource? _cts; private readonly string _employeesFilePath = Path.Combine(Path.Combine(AppContext.BaseDirectory, AppConsts.DataFolderName), AppConsts.EmployeesFileName); public async Task)>> GetEmployees(string fullname, int size = 10) { + if (string.IsNullOrEmpty(fullname)) + return _employees + .OrderBy(e => e.Key) + .Take(size) + .ToDictionary(e => e.Key, e => e.Value); + return _employees .Where(e => e.Key.Contains(fullname, StringComparison.OrdinalIgnoreCase)) + .OrderBy(e => e.Key) .Take(size) .ToDictionary(e => e.Key, e => e.Value); }