private void UpdateQueue() { var groups = new List <GroupQueueItem>(); foreach (var group in GroupsList.ToArray()) { var nextGroup = groups.Where(g => g.GroupSize + group.GroupSize <= MaxGroupSize).FirstOrDefault(); if (nextGroup == null) { var newGroup = new GroupQueueItem(); newGroup.GroupName = GetGroupName(); newGroup.Groups.Add(group); groups.Add(newGroup); } else { nextGroup.Groups.Add(group); } } var groupList = GroupsList.OrderBy(g => g.GroupNumber).ToList(); GroupsList.Clear(); GroupsQueue.Clear(); foreach (var group in groupList) { GroupsList.Add(group); } foreach (var group in groups) { GroupsQueue.Add(group); } }
public void GetGroupsWellsLists() { Records?.ForEach(record => { if (record.GetType() == typeof(GroupRecord)) { GroupsList.Add((GroupRecord)record); } else { WellsList.Add((WellRecord)record); } }); }
public void OnMembershipsDataUpdate(object data) { Memberships = (IEnumerable <MembershipDTO>)data; List <int> missingGroups = new List <int>(); GroupsList.Clear(); InvitedGroupList.Clear(); foreach (var membership in Memberships) { GroupModel groupModel; if (membership.Status == 0) { groupModel = new GroupModel(OnGroupAccept, OnGroupDecline); } else { groupModel = new GroupModel(OnGroupEnter, null); } GroupDTO groupDTO = Groups.Where(p => p.Id == membership.GroupId).FirstOrDefault(); if (groupDTO != null) { UpdateGroupModel(groupModel, groupDTO); } else { missingGroups.Add(membership.GroupId); } if (membership.Status == 0) { InvitedGroupList.Add(groupModel); } else { GroupsList.Add(groupModel); } } if (missingGroups.Count > 0) { DataManager.GetData(DataManager.DataType.Groups, OnGroupsDataUpdate); } }
private void OnAddGroupCommand() { TotalGroups++; TotalPeople += CurrentGroupSize; AverageSize = Math.Round(((double)TotalPeople) / ((double)TotalGroups), 2); GroupsList.Add(new Group() { GroupNumber = CurrentGroupNumber, GroupSize = CurrentGroupSize, }); CurrentGroupSize = 0; CurrentGroupSizeStr = ""; CurrentGroupNumber = 0; CurrentGroupNumberStr = ""; RaiseChanged(nameof(CurrentGroupSize), nameof(CurrentGroupNumber), nameof(TotalGroups), nameof(TotalPeople), nameof(AverageSize)); OnSetGroupNumberCommand(); UpdateQueue(); }