public List <List <Talks> > GetScheduleConferenceTrack(List <Talks> talksList) { int perDayMinTime = 6 * 60; int totalTalksTime = _utils.GetTotalTalksTime(talksList); int totalPossibleDays = totalTalksTime / perDayMinTime; List <Talks> list = new List <Talks>(); list.AddRange(talksList); List <Talks> talksListForOperation = list.OrderByDescending(x => x.TimeDuration).ToList(); List <List <Talks> > combForMornSessions = _utils.FindPossibleCombSession(talksListForOperation, totalPossibleDays, true); talksListForOperation = combForMornSessions.Aggregate(talksListForOperation, (current, talkList) => current.Except(talkList).ToList()); List <List <Talks> > combForEveSessions = _utils.FindPossibleCombSession(talksListForOperation, totalPossibleDays, false); talksListForOperation = combForEveSessions.Aggregate(talksListForOperation, (current, talkList) => current.Except(talkList).ToList()); int maxSessionTimeLimit = 240; List <Talks> scheduledTalkList = new List <Talks>(); if (talksListForOperation.Count != 0) { foreach (var talkList in combForEveSessions) { var totalTime = _utils.GetTotalTalksTime(talkList); foreach (Talks talk in talksListForOperation) { int talkTime = talk.TimeDuration; if (talkTime + totalTime <= maxSessionTimeLimit) { talkList.Add(talk); talk.Scheduled = true; scheduledTalkList.Add(talk); } } talksListForOperation = talksListForOperation.Except(scheduledTalkList).ToList(); if (talksListForOperation.Count == 0) { break; } } } if (talksListForOperation.Count != 0) { throw new Exception("Unable to schedule all task for conferencing."); } return(GetScheduledTalksList(combForMornSessions, combForEveSessions)); }