diff --git a/SfeduSchedule.Abstractions/AttendeesDTO.cs b/SfeduSchedule.Abstractions/AttendeesDTO.cs new file mode 100644 index 0000000..bdbf41d --- /dev/null +++ b/SfeduSchedule.Abstractions/AttendeesDTO.cs @@ -0,0 +1,63 @@ +using System.Text.Json; +using System.Text.Json.Serialization; + +#nullable enable +#pragma warning disable CS8618 +#pragma warning disable CS8601 +#pragma warning disable CS8603 + +namespace SfeduSchedule.Abstractions; + +public partial class Attendees +{ + public static List FromJson(string json) => JsonSerializer.Deserialize>(json); +} + +public partial class Attendees +{ + [JsonPropertyName("id")] + public Guid Id { get; set; } + + [JsonPropertyName("roleId")] + public string RoleId { get; set; } + + [JsonPropertyName("roleName")] + public string RoleName { get; set; } + + [JsonPropertyName("roleNamePlural")] + public string RoleNamePlural { get; set; } + + [JsonPropertyName("roleDisplayOrder")] + public long RoleDisplayOrder { get; set; } + + [JsonPropertyName("personId")] + public Guid PersonId { get; set; } + + [JsonPropertyName("lastName")] + public string LastName { get; set; } + + [JsonPropertyName("firstName")] + public string FirstName { get; set; } + + [JsonPropertyName("middleName")] + public string MiddleName { get; set; } + + [JsonPropertyName("fullName")] + public string FullName { get; set; } + + [JsonPropertyName("studentId")] + public Guid? StudentId { get; set; } + + [JsonPropertyName("specialtyCode")] + public string SpecialtyCode { get; set; } + + [JsonPropertyName("specialtyName")] + public string SpecialtyName { get; set; } + + [JsonPropertyName("specialtyProfile")] + public string SpecialtyProfile { get; set; } +} + +#pragma warning restore CS8618 +#pragma warning restore CS8601 +#pragma warning restore CS8603 \ No newline at end of file diff --git a/SfeduSchedule/Services/ModeusService.cs b/SfeduSchedule/Services/ModeusService.cs index c9ddef0..0083304 100644 --- a/SfeduSchedule/Services/ModeusService.cs +++ b/SfeduSchedule/Services/ModeusService.cs @@ -38,6 +38,30 @@ namespace SfeduSchedule.Services } return await response.Content.ReadAsStringAsync(); } + + public async Task> GetAttendeesAsync(Guid eventId) + { + var request = new HttpRequestMessage(HttpMethod.Get, + $"schedule-calendar-v2/api/calendar/events/{eventId}/attendees"); + var response = await _httpClient.SendAsync(request); + _logger.LogInformation("GetAttendeesAsync: Ответ получен: {StatusCode}", response.StatusCode); + if (response.StatusCode != System.Net.HttpStatusCode.OK) + { + _logger.LogError("GetAttendeesAsync: Ошибка при получении списка студентов: {StatusCode}", response.StatusCode); + return new List(); + } + List? attendees; + try + { + attendees = Attendees.FromJson(await response.Content.ReadAsStringAsync()); + return attendees; + } + catch (Exception ex) + { + _logger.LogError(ex, "GetAttendeesAsync: Deserialization failed."); + } + return new List(); + } public async Task SearchRoomsAsync(RoomSearchRequest requestDto) {