Exemplo n.º 1
0
        private void setTuteeLocations()
        {
            TutorMasterDBEntities4 db = new TutorMasterDBEntities4();                                          //Connect to the database
            string loc = txtLoc.Text;                                                                          //grab the text of the location the tutor typed in

            for (int i = 0; i < info.Count(); i++)                                                             //for every time chosen
            {
                DateTime startDate = DateTimeMethods.getStartTime(info[i]);                                    //get the startTime
                DateTime endDate   = DateTimeMethods.getEndTime(info[i]);                                      //get the endTime

                int partnerID = Convert.ToInt32(info[i].Split(',')[2]);

                List <Commitment> tuteeCmtList = (from stucmt in db.StudentCommitments                          //get the tutee's commitments
                                                  where stucmt.ID == partnerID
                                                  join cmt in db.Commitments on stucmt.CmtID equals cmt.CmtID
                                                  select cmt).ToList();
                //if a commitment is in the time slot
                for (int m = 0; m < tuteeCmtList.Count(); m++)                                                 //go through the tutee commitments
                {
                    if (DateTimeMethods.inTheTimeSlot(startDate, endDate, tuteeCmtList[m]))
                    {
                        tuteeCmtList[m].Class = tuteeCmtList[m].Class + "!";                                   //add an exclamation point to the tutee class so that the system knows this is a new commitment
                        if (!admin)
                        {
                            tuteeCmtList[m].Location = loc + "?";                                                  //change the location to the string the user typed in + a question mark
                        }
                        else
                        {
                            tuteeCmtList[m].Location = loc;
                        }
                        db.SaveChanges();                                                                      //save to database
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void setTutorLocations()
        {
            TutorMasterDBEntities4 db      = new TutorMasterDBEntities4();                                           //Connect to the database
            string            loc          = txtLoc.Text;                                                            //grab the text of the location the tutor typed in
            List <Commitment> tutorCmtList = (from stucmt in db.StudentCommitments                                   //get the tutor's commitments
                                              where stucmt.ID == id
                                              join cmt in db.Commitments on stucmt.CmtID equals cmt.CmtID
                                              select cmt).ToList();

            for (int i = 0; i < info.Count(); i++)                                                                   //for every time chosen
            {
                DateTime startDate = DateTimeMethods.getStartTime(info[i]);                                          //get the startTime
                DateTime endDate   = DateTimeMethods.getEndTime(info[i]);                                            //get the endTime
                for (int c = 0; c < tutorCmtList.Count(); c++)                                                       //go through the tutor commitments
                {
                    if (DateTimeMethods.inTheTimeSlot(startDate, endDate, tutorCmtList[c]))                          //if a commitment is in the time slot
                    {
                        if (!admin)
                        {
                            tutorCmtList[c].Location = loc + "?";                                                        //change the location to the string the user typed in + a question mark
                        }
                        else
                        {
                            tutorCmtList[c].Location = loc;                                                          //change the location to the string the user typed in
                        }
                        db.SaveChanges();                                                                            //save to database
                    }
                }
            }
        }
        private int getNumSession(string info)
        {
            int      numSession = 0;
            string   startTime  = info.Split(',')[0];
            string   endTime    = info.Split(',')[1];
            string   timeSlot   = startTime + "," + endTime;              //load a timeslot string
            DateTime start      = DateTimeMethods.getStartTime(timeSlot); //get the datetime start time
            DateTime end        = DateTimeMethods.getEndTime(timeSlot);   //get the datetime end time

            while (DateTime.Compare(start, end) < 0)
            {
                numSession++;                                        //increment numsessions until you get to appropriate value
                start = start.AddMinutes(15);
            }
            return(numSession);
        }
Exemplo n.º 4
0
        private void addCommits(string timeSlot, int tutorId, int tuteeId, List <TutorMaster.Commitment> tutorCommits, List <TutorMaster.Commitment> tuteeCommits, string classCode, TutorMasterDBEntities4 db, bool weekly, int numSessions)
        {
            DateTime startTime = DateTimeMethods.getStartTime(timeSlot);               //get the start time of the time slot
            DateTime endTime   = DateTimeMethods.getEndTime(timeSlot);                 //get the end time of the time slot
            DateTime saveFirst = startTime;                                            //make copies of them
            DateTime saveEnd   = endTime;


            if (!weekly)                                                               //if the request is not weekly
            {
                for (int j = 0; j < tuteeCommits.Count(); j++)
                {
                    if (DateTime.Compare(startTime, Convert.ToDateTime(tuteeCommits[j].StartTime)) <= 0 && DateTime.Compare(endTime, Convert.ToDateTime(tuteeCommits[j].StartTime)) > 0)
                    {                                                                  //if the commitment's start time is between the end time and start time, update it to a new appointment
                        tuteeCommits[j].Open     = false;
                        tuteeCommits[j].Tutoring = false;
                        tuteeCommits[j].ID       = tutorId;
                        tuteeCommits[j].Class    = classCode + "!";
                        tuteeCommits[j].Weekly   = false;
                        db.SaveChanges();
                    }
                    else if (DateTime.Compare(endTime, Convert.ToDateTime(tuteeCommits[j].StartTime)) <= 0)
                    {                                                                  //else, break out of this for loop
                        break;
                    }
                }

                for (int i = 0; i < tutorCommits.Count(); i++)
                {
                    if (DateTime.Compare(startTime, Convert.ToDateTime(tutorCommits[i].StartTime)) <= 0 && DateTime.Compare(endTime, Convert.ToDateTime(tutorCommits[i].StartTime)) > 0)
                    {                                                                 //if the commitment's start time is between the end time and start time, update it to a new appointment
                        tutorCommits[i].Open     = false;
                        tutorCommits[i].Tutoring = true;
                        tutorCommits[i].ID       = tuteeId;
                        tutorCommits[i].Class    = classCode + "!";
                        tutorCommits[i].Weekly   = false;
                        db.SaveChanges();
                    }
                    else if (DateTime.Compare(endTime, Convert.ToDateTime(tutorCommits[i].StartTime)) <= 0)
                    {                                                                   //else, break out of this for loop
                        break;
                    }
                }
            }
            else
            {
                for (int j = 0; j < tuteeCommits.Count(); j++)
                {
                    if (DateTime.Compare(startTime, Convert.ToDateTime(tuteeCommits[j].StartTime)) <= 0 && DateTime.Compare(endTime, Convert.ToDateTime(tuteeCommits[j].StartTime)) > 0)
                    {
                        if (!tuteeCommits[j].Class.ToString().Contains('!'))
                        {                                                               //if the commitment is between the start and end times, put it as an appointment
                            tuteeCommits[j].Open     = false;
                            tuteeCommits[j].Tutoring = false;
                            tuteeCommits[j].ID       = tutorId;
                            tuteeCommits[j].Class    = classCode + "!";
                            db.SaveChanges();
                        }
                    }
                    else if (DateTime.Compare(endTime, Convert.ToDateTime(tuteeCommits[j].StartTime)) <= 0)
                    {                                                                  //if it is after end time, move our range forward a week
                        startTime = startTime.AddDays(7);
                        endTime   = endTime.AddDays(7);
                        j--;
                    }
                }
                startTime = saveFirst;
                endTime   = saveEnd;
                for (int i = 0; i < tutorCommits.Count(); i++)
                {
                    if (DateTime.Compare(startTime, Convert.ToDateTime(tutorCommits[i].StartTime)) <= 0 && DateTime.Compare(endTime, Convert.ToDateTime(tutorCommits[i].StartTime)) > 0)
                    {
                        if (!tutorCommits[i].Class.ToString().Contains('!'))
                        {                                                              //if tutor commits is in the range, change it to a new appointment
                            tutorCommits[i].Open     = false;
                            tutorCommits[i].Tutoring = true;
                            tutorCommits[i].ID       = tuteeId;
                            tutorCommits[i].Class    = classCode + "!";
                            db.SaveChanges();
                        }
                    }
                    else if (DateTime.Compare(endTime, Convert.ToDateTime(tutorCommits[i].StartTime)) <= 0)
                    {                                                                  //if it is after end time, move our range forward a week
                        startTime = startTime.AddDays(7);
                        endTime   = endTime.AddDays(7);
                        i--;
                    }
                }
            }
        }
        private void addCommits(string timeSlot, int tutorId, int tuteeId, List <TutorMaster.Commitment> tutorCommits, List <TutorMaster.Commitment> tuteeCommits, string classCode, TutorMasterDBEntities4 db, bool weekly, int numSessions)
        {
            DateTime startTime = DateTimeMethods.getStartTime(timeSlot); //get the start time of the time block
            DateTime endTime   = DateTimeMethods.getEndTime(timeSlot);   //get the end time of the time block
            DateTime saveFirst = startTime;                              //save copies of them
            DateTime saveEnd   = endTime;


            if (!weekly)                                                //if this is not weekly
            {
                for (int j = 0; j < tuteeCommits.Count(); j++)
                {
                    if (DateTime.Compare(startTime, Convert.ToDateTime(tuteeCommits[j].StartTime)) <= 0 && DateTime.Compare(endTime, Convert.ToDateTime(tuteeCommits[j].StartTime)) > 0)
                    {//if the tutee commit's start time is between our interval, then update the commitment to a finalized state
                        tuteeCommits[j].Location = tbxLocation.Text.ToString();
                        tuteeCommits[j].Open     = false;
                        tuteeCommits[j].Tutoring = false;
                        tuteeCommits[j].ID       = tutorId;
                        tuteeCommits[j].Class    = classCode + "!";
                        tuteeCommits[j].Weekly   = false;
                        db.SaveChanges();
                    }
                    else if (DateTime.Compare(endTime, Convert.ToDateTime(tuteeCommits[j].StartTime)) <= 0)
                    {//if its not, then break out the loop
                        break;
                    }
                }

                for (int i = 0; i < tutorCommits.Count(); i++)
                {
                    if (DateTime.Compare(startTime, Convert.ToDateTime(tutorCommits[i].StartTime)) <= 0 && DateTime.Compare(endTime, Convert.ToDateTime(tutorCommits[i].StartTime)) > 0)
                    {//if the tutor commit's start time is between our interval, then update the commitment to a finalized state
                        tutorCommits[i].Location = tbxLocation.Text.ToString();
                        tutorCommits[i].Open     = false;
                        tutorCommits[i].Tutoring = true;
                        tutorCommits[i].ID       = tuteeId;
                        tutorCommits[i].Class    = classCode + "!";
                        tutorCommits[i].Weekly   = false;
                        db.SaveChanges();
                    }
                    else if (DateTime.Compare(endTime, Convert.ToDateTime(tutorCommits[i].StartTime)) <= 0)
                    {//if its not, break out of the loop
                        break;
                    }
                }
            }
            else   //if the admin chooses to have this be a weekly appointment
            {
                for (int j = 0; j < tuteeCommits.Count(); j++)
                {
                    if (DateTime.Compare(startTime, Convert.ToDateTime(tuteeCommits[j].StartTime)) <= 0 && DateTime.Compare(endTime, Convert.ToDateTime(tuteeCommits[j].StartTime)) > 0)
                    {//if the tutee commitment is between the time slot, put it to a finalized state
                        if (!tuteeCommits[j].Class.ToString().Contains('!'))
                        {
                            tuteeCommits[j].Location = tbxLocation.Text.ToString();
                            tuteeCommits[j].Open     = false;
                            tuteeCommits[j].Tutoring = false;
                            tuteeCommits[j].ID       = tutorId;
                            tuteeCommits[j].Class    = classCode + "!";
                        }
                        db.SaveChanges();
                    }
                    else if (DateTime.Compare(endTime, Convert.ToDateTime(tuteeCommits[j].StartTime)) <= 0)
                    {//if its above our current endTime, then move startTime and endTime up a week
                        startTime = startTime.AddDays(7);
                        endTime   = endTime.AddDays(7);
                        j--;
                    }
                }
                startTime = saveFirst;//reset the start and end times
                endTime   = saveEnd;
                for (int i = 0; i < tutorCommits.Count(); i++)
                {
                    if (DateTime.Compare(startTime, Convert.ToDateTime(tutorCommits[i].StartTime)) <= 0 && DateTime.Compare(endTime, Convert.ToDateTime(tutorCommits[i].StartTime)) > 0)
                    {//if the tutor commitment is between the time slot, put it to a finalized state
                        if (!tutorCommits[i].Class.ToString().Contains('!'))
                        {
                            tutorCommits[i].Location = tbxLocation.Text.ToString();
                            tutorCommits[i].Open     = false;
                            tutorCommits[i].Tutoring = true;
                            tutorCommits[i].ID       = tuteeId;
                            tutorCommits[i].Class    = classCode + "!";
                        }
                        db.SaveChanges();
                    }
                    else if (DateTime.Compare(endTime, Convert.ToDateTime(tutorCommits[i].StartTime)) <= 0)
                    {//if its above our current endTime, then move startTime and endTime up a week
                        startTime = startTime.AddDays(7);
                        endTime   = endTime.AddDays(7);
                        i--;
                    }
                }
            }
        }