private void AssignGroup(int groupNumber, List <GroupStudent> newGroupStudentList, Student studentToAssign) { List <GroupStudent> currentGroupStudentList = _groupStudentDBManager.GetAll(); List <Group> allGroups = _groupDBManager.GetAll(); Group targetGroup = allGroups.Find(group => group.GroupId == groupNumber); GroupStudent targetGroupStudent = newGroupStudentList.Find(groupStudent => groupStudent.GroupId == targetGroup.GroupId); if (targetGroupStudent == null) { targetGroupStudent = new GroupStudent() { GroupId = targetGroup.GroupId, Students = new List <Student>() }; newGroupStudentList.Add(targetGroupStudent); } if ( targetGroup != null && targetGroupStudent.Students.Count < targetGroup.MaxNumberOfStudents ) { targetGroupStudent.Students.Add(studentToAssign); return; } else { int groupNumnber; if (WasInBigGroup(studentToAssign)) { groupNumnber = GetAGroupNumber(1, 3, targetGroup.GroupId); } else { groupNumnber = GetAGroupNumber(1, 5, targetGroup.GroupId); } AssignGroup(groupNumnber, newGroupStudentList, studentToAssign); } }
public List <GroupDTO> GetAll() { return(DTOUtil.MapGroupDTOList(_groupDBManager.GetAll())); }