|
1 | 1 | using JoinRpg.DataModel; |
| 2 | +using JoinRpg.PrimitiveTypes; |
2 | 3 | using JoinRpg.PrimitiveTypes.ProjectMetadata; |
3 | 4 |
|
4 | 5 | namespace JoinRpg.Domain.Schedules; |
@@ -102,24 +103,23 @@ private void PutItem(ProgramItem programItem, List<ProgramItemSlot> slots) |
102 | 103 |
|
103 | 104 | private List<ProgramItemSlot> SelectSlots(ProgramItem programItem, Character character) |
104 | 105 | { |
105 | | - var fields = character.GetFields(projectInfo); |
| 106 | + var fields = character.GetFieldsDict(projectInfo); |
106 | 107 |
|
107 | | - List<int> GetSlotIndexes(ProjectFieldInfo field, IEnumerable<ScheduleItemAttribute> items) |
| 108 | + int[] GetSlotIndexes(FieldWithValue field, IEnumerable<ScheduleItemAttribute> items) |
108 | 109 | { |
109 | | - var variantIds = field.SortedVariants |
110 | | - .Select(variant => variant.Id) |
111 | | - .ToList(); |
112 | | - var indexes = (from item in items where variantIds.Contains(item.Id) select item.SeqId).ToList(); |
113 | | - if (indexes.Count < variantIds.Count) // Some variants not found, probably deleted |
| 110 | + ProjectFieldVariantIdentification[] variantIds = [.. field.GetDropdownValues().Select(variant => variant.Id)]; |
| 111 | + |
| 112 | + int[] indexes = [.. (from item in items where variantIds.Contains(item.Id) select item.SeqId)]; |
| 113 | + if (indexes.Length < variantIds.Length) // Some variants not found, probably deleted |
114 | 114 | { |
115 | 115 | _ = NotScheduled.Add(programItem); |
116 | 116 | } |
117 | 117 |
|
118 | 118 | return indexes; |
119 | 119 | } |
120 | 120 |
|
121 | | - var slots = from timeSeqId in GetSlotIndexes(TimeSlotField, TimeSlots) |
122 | | - from roomSeqId in GetSlotIndexes(RoomField, Rooms) |
| 121 | + var slots = from timeSeqId in GetSlotIndexes(fields[TimeSlotField.Id], TimeSlots) |
| 122 | + from roomSeqId in GetSlotIndexes(fields[RoomField.Id], Rooms) |
123 | 123 | select Slots[timeSeqId][roomSeqId]; |
124 | 124 |
|
125 | 125 | return slots.ToList(); |
|
0 commit comments