Exemplo n.º 1
0
        //this function makes sure that we do not take a time that is already at 3 hours and add to it
        private void checkMax(ref List <TutorMaster.Commitment> cmtList)
        {
            int consec = 1;

            for (int i = 0; i < cmtList.Count() - 1; i++)
            {
                DateTime currentCommit = Convert.ToDateTime(cmtList[i].StartTime);                                                                                          //get the current commitment's starttime
                DateTime nextCommit    = Convert.ToDateTime(cmtList[i + 1].StartTime);                                                                                      //get the next commitment's starttime

                if (consec > 11)                                                                                                                                            //if the consecutive counter is above 11, then remove the next commitment
                {
                    if (DateTime.Compare(currentCommit.AddMinutes(15), nextCommit) == 0 && Commits.sameCategory(cmtList[i], cmtList[i + 1]) && !Commits.isOpen(cmtList[i])) //if it is adjacent as well, remove the next commitment
                    {
                        cmtList.Remove(cmtList[i + 1]);
                        i--;
                    }
                    consec = 1;                                                                                                                                         //set commit counter to 0
                }
                if (DateTime.Compare(currentCommit.AddMinutes(15), nextCommit) == 0 && Commits.sameCategory(cmtList[i], cmtList[i + 1]) && !Commits.isOpen(cmtList[i])) //if the next commit is adjacent, then increment consec counter
                {
                    consec++;
                }
                else
                {
                    consec = 1;
                }
            }
        }
Exemplo n.º 2
0
 public static bool openOrSameType(Commitment listCommit, Commitment midCommit)
 {
     return(midCommit.Open == true || Commits.sameCategory(listCommit, midCommit));
 }