예제 #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
                    }
                }
            }
        }
예제 #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
                    }
                }
            }
        }