Правка регистрации, расписание, смена ролей
This commit is contained in:
@@ -6,6 +6,14 @@ namespace Nashel.Modules.Identity.Application.Queries.GetProfile;
|
||||
|
||||
public record GetProfileQuery : IRequest<ProfileResponse>;
|
||||
|
||||
public record WorkScheduleResponse(
|
||||
bool Is24_7,
|
||||
bool IsAlwaysReady,
|
||||
List<string>? WorkingDays,
|
||||
string? WorkingHoursStart,
|
||||
string? WorkingHoursEnd
|
||||
);
|
||||
|
||||
public record ProfileResponse(
|
||||
Guid Id,
|
||||
string Phone,
|
||||
@@ -18,7 +26,8 @@ public record ProfileResponse(
|
||||
string? Description,
|
||||
string FullName,
|
||||
string? AvatarUrl,
|
||||
List<string> Competencies);
|
||||
List<string> Competencies,
|
||||
WorkScheduleResponse? WorkSchedule);
|
||||
|
||||
public class GetProfileQueryHandler : IRequestHandler<GetProfileQuery, ProfileResponse>
|
||||
{
|
||||
@@ -51,6 +60,38 @@ public class GetProfileQueryHandler : IRequestHandler<GetProfileQuery, ProfileRe
|
||||
fullName += $" {account.Profile.Patronymic}";
|
||||
}
|
||||
|
||||
// Парсинг WorkSchedule
|
||||
WorkScheduleResponse? workScheduleResponse = null;
|
||||
if (account.Profile.WorkSchedule != null)
|
||||
{
|
||||
var workingDays = account.Profile.WorkSchedule.WorkingDays != null
|
||||
? System.Text.Json.JsonSerializer.Deserialize<List<string>>(account.Profile.WorkSchedule.WorkingDays)
|
||||
: null;
|
||||
|
||||
string? workingHoursStart = null;
|
||||
string? workingHoursEnd = null;
|
||||
if (account.Profile.WorkSchedule.WorkingHours != null)
|
||||
{
|
||||
var workingHours = System.Text.Json.JsonSerializer.Deserialize<System.Text.Json.JsonElement>(account.Profile.WorkSchedule.WorkingHours);
|
||||
if (workingHours.TryGetProperty("start", out var start))
|
||||
{
|
||||
workingHoursStart = start.GetString();
|
||||
}
|
||||
if (workingHours.TryGetProperty("end", out var end))
|
||||
{
|
||||
workingHoursEnd = end.GetString();
|
||||
}
|
||||
}
|
||||
|
||||
workScheduleResponse = new WorkScheduleResponse(
|
||||
account.Profile.WorkSchedule.Is24_7,
|
||||
account.Profile.WorkSchedule.IsAlwaysReady,
|
||||
workingDays,
|
||||
workingHoursStart,
|
||||
workingHoursEnd
|
||||
);
|
||||
}
|
||||
|
||||
return new ProfileResponse(
|
||||
account.Id,
|
||||
account.Phone,
|
||||
@@ -63,6 +104,7 @@ public class GetProfileQueryHandler : IRequestHandler<GetProfileQuery, ProfileRe
|
||||
account.Profile.Description,
|
||||
fullName,
|
||||
account.Profile.AvatarUrl,
|
||||
account.Profile.Competencies.Select(c => c.Name).ToList());
|
||||
account.Profile.Competencies.Select(c => c.Name).ToList(),
|
||||
workScheduleResponse);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user