From 3ac1fefcfe5c1611ec0e16940d542b38d87c4d42 Mon Sep 17 00:00:00 2001 From: Sergey Karmanov Date: Sun, 31 Aug 2025 17:10:49 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/ScheduleController.cs | 26 +++++++++++++++++-- SfeduSchedule/Controllers/SfeduController.cs | 15 ++++++++++- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/SfeduSchedule/Controllers/ScheduleController.cs b/SfeduSchedule/Controllers/ScheduleController.cs index 9969e3f..3179a1d 100644 --- a/SfeduSchedule/Controllers/ScheduleController.cs +++ b/SfeduSchedule/Controllers/ScheduleController.cs @@ -11,14 +11,36 @@ namespace SfeduSchedule.Controllers public ScheduleController(ModeusService modeusService) => _modeusService = modeusService; + /// + /// Получить расписание для указанных пользователей. + /// + /// Список GUID пользователей, для которых запрашивается расписание. + /// Список событий расписания. + /// Возвращает расписание [HttpGet] - public async Task Get([FromQuery] List attendeePersonId) + public async Task Get([FromQuery] List attendeePersonId, [FromQuery] DateTime? startDate, [FromQuery] DateTime? endDate) { - var msr = new ModeusScheduleRequest(500, DateTime.UtcNow, DateTime.UtcNow.AddDays(20), attendeePersonId); + if (!startDate.HasValue) + { + startDate = DateTime.UtcNow; + } + + if (!endDate.HasValue) + { + endDate = DateTime.UtcNow.AddDays(20); + } + + var msr = new ModeusScheduleRequest(500, (DateTime)startDate, (DateTime)endDate, attendeePersonId); var schedule = await _modeusService.GetScheduleAsync(msr); return Ok(schedule); } + /// + /// Получить расписание по пользовательскому запросу. + /// + /// Объект запроса, содержащий параметры фильтрации расписания. + /// Список событий расписания. + /// Возвращает расписание [HttpPost] public async Task Post([FromBody] ModeusScheduleRequest request) { diff --git a/SfeduSchedule/Controllers/SfeduController.cs b/SfeduSchedule/Controllers/SfeduController.cs index 15854e5..8a1fcf8 100644 --- a/SfeduSchedule/Controllers/SfeduController.cs +++ b/SfeduSchedule/Controllers/SfeduController.cs @@ -13,9 +13,17 @@ namespace SfeduSchedule.Controllers public SfeduController(ModeusService modeusService) => _modeusService = modeusService; + /// + /// Получить GUID пользователя через авторизацию Microsoft. + /// + /// Необязательный параметр. Если указан, произойдет редирект на указанный URI после получения GUID. (/?guid=XXX) + /// Строка GUID пользователя или редирект на указанный URI. + /// Возвращает GUID пользователя + /// Редирект на указанный URI + /// Ошибка при получении имени пользователя или GUID [HttpGet] [Route("guid")] - public async Task Get() + public async Task Get([FromQuery] string? redirectUri) { var name = User.FindFirst("name")?.Value; if (string.IsNullOrEmpty(name)) @@ -25,6 +33,11 @@ namespace SfeduSchedule.Controllers if (string.IsNullOrEmpty(guid)) return StatusCode(StatusCodes.Status500InternalServerError); + if (!string.IsNullOrEmpty(redirectUri)) + { + return Redirect(redirectUri + "?guid=" + guid); + } + return Ok(guid); }