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 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); } }