Skip to content

Commit a6d13c2

Browse files
authored
Use ProjectInfo in Schedule (#2412)
1 parent 6688ee5 commit a6d13c2

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/JoinRpg.WebPortal.Managers/Schedule/SchedulePageManager.cs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using JoinRpg.Domain.Schedules;
99
using JoinRpg.Interfaces;
1010
using JoinRpg.Markdown;
11+
using JoinRpg.PrimitiveTypes.ProjectMetadata;
1112
using JoinRpg.Web.Models.Schedules;
1213
using JoinRpg.WebPortal.Managers.Interfaces;
1314

@@ -116,7 +117,7 @@ private void BuildAppointments(Project project, SchedulePageViewModel viewModel)
116117
{
117118
ErrorType = viewModel.ConflictedProgramItems.FirstOrDefault(pi => pi.Id == slot.Id) != null
118119
? AppointmentErrorType.Intersection
119-
: (AppointmentErrorType?)null,
120+
: null,
120121
AllRooms = slot.ColSpan == viewModel.Columns.Count,
121122
RoomIndex = colIndex,
122123
RoomCount = slot.ColSpan,
@@ -236,13 +237,22 @@ int CountSameSlots(IEnumerable<ProgramItemViewModel> sameSlots)
236237
public async Task<IReadOnlyCollection<ScheduleConfigProblemsViewModel>> CheckScheduleConfiguration()
237238
{
238239
var project = await Project.GetProjectWithFieldsAsync(CurrentProject.ProjectId);
240+
ProjectInfo projectInfo;
241+
try
242+
{
243+
projectInfo = await projectMetadataRepository.GetProjectMetadata(CurrentProject.ProjectId);
244+
}
245+
catch (InvalidOperationException)
246+
{
247+
return new[] { ScheduleConfigProblemsViewModel.ProjectNotFound };
248+
}
239249

240250
if (project is null)
241251
{
242252
return new[] { ScheduleConfigProblemsViewModel.ProjectNotFound };
243253
}
244254

245-
bool HasAccess(ProjectField roomField)
255+
bool HasAccess(ProjectFieldInfo roomField)
246256
{
247257
if (roomField.IsPublic)
248258
{
@@ -261,8 +271,8 @@ bool HasAccess(ProjectField roomField)
261271

262272
IEnumerable<ScheduleConfigProblemsViewModel> Impl()
263273
{
264-
var roomField = project.GetRoomFieldOrDefault();
265-
var timeSlotField = project.GetTimeSlotFieldOrDefault();
274+
var roomField = projectInfo.RoomField;
275+
var timeSlotField = projectInfo.TimeSlotField;
266276
if (roomField is null || timeSlotField is null)
267277
{
268278
yield return ScheduleConfigProblemsViewModel.FieldsNotSet;
@@ -279,12 +289,12 @@ IEnumerable<ScheduleConfigProblemsViewModel> Impl()
279289
yield return ScheduleConfigProblemsViewModel.NoAccess;
280290
}
281291

282-
if (!timeSlotField.DropdownValues.Any())
292+
if (!timeSlotField.Variants.Any())
283293
{
284294
yield return ScheduleConfigProblemsViewModel.NoTimeSlots;
285295
}
286296

287-
if (!roomField.DropdownValues.Any())
297+
if (!roomField.Variants.Any())
288298
{
289299
yield return ScheduleConfigProblemsViewModel.NoRooms;
290300
}
@@ -296,7 +306,6 @@ IEnumerable<ScheduleConfigProblemsViewModel> Impl()
296306

297307
public async Task<ScheduleBuilder> GetBuilder()
298308
{
299-
var project = await Project.GetProjectWithFieldsAsync(CurrentProject.ProjectId);
300309
var characters = await Project.GetCharacters(CurrentProject.ProjectId);
301310

302311
var projectInfo = await projectMetadataRepository.GetProjectMetadata(CurrentProject.ProjectId);

0 commit comments

Comments
 (0)