Пример #1
0
 public bool Exists(TutoringSession ts)
 {
     using (var context = new LabManagerDbContext())
     {
         return(context.TutoringSession.Any(x => x.Equals(ts)));
     }
 }
Пример #2
0
        public void UpdateTutoringSession(TutoringSession ts)
        {
            if (ts != null)
            {
                try
                {
                    //Vi måste väl ta bort tutoingsession ur kursen och lägga till en ny väl?

                    Course tmpCourse = Courses.FirstOrDefault(c => c.Code.Equals(ts.Code));
                    TutoringSessionUpdateDTO tsDTO = new TutoringSessionUpdateDTO(selectedTutoringSession, ts);
                    dal.UpdateTutoringSession(tsDTO);

                    Status = "Tutoring Session was updated";
                }
                catch (Exception ex)
                {
                    Status = ExceptionHandler.GetErrorMessage(ex);
                }

                TutoringSessions = new ObservableCollection <TutoringSession>(dal.GetAllTutoringSessions());
                NotifyPropertyChanged("TutoringSessions");

                Courses = new ObservableCollection <Course>(dal.GetAllCourses());
                NotifyPropertyChanged("Courses");

                SelectedTutoringSession = null;
                NotifyPropertyChanged("SelectedTutoringSession");

                SelectedCourse = Courses.FirstOrDefault(c => c.Code.Equals(ts.Code));
                NotifyPropertyChanged("SelectedCourse");
            }
        }
Пример #3
0
        public void AddTutor(TutoringSession ts)
        {
            if (ts != null)
            {
                TutorTutoringSession tmptts = new TutorTutoringSession(selectedTutor, ts);
                try
                {
                    TutoringSessionUpdateDTO updateDTO = new TutoringSessionUpdateDTO(ts, ts);

                    ts.Tutors.Add(tmptts);
                    selectedTutor.TutoringSessions.Add(tmptts);

                    dal.UpdateTutoringSession(updateDTO);

                    Status = "Added to planned sessions";
                }
                catch (Exception ex)
                {
                    // Rollback
                    ts.Tutors.Remove(tmptts);
                    selectedTutor.TutoringSessions.Remove(tmptts);
                    Status = ExceptionHandler.GetErrorMessage(ex);
                }
                NotifyPropertyChanged("TutorTutoredHours");
                NotifyPropertyChanged("TutorPlannedHours");
                NotifyPropertyChanged("TutorLastSession");
                NotifyPropertyChanged("TutorNextSession");
                NotifyPropertyChanged("AvailableTutoringSessions");
                NotifyPropertyChanged("PlannedTutoringSessions");
            }
        }
Пример #4
0
 public void AddTutoringSession(TutoringSession ts)
 {
     using (var context = new LabManagerDbContext())
     {
         context.TutoringSession.Add(ts);
         context.SaveChanges();
     }
 }
Пример #5
0
        public void UpdateTutoringSession(TutoringSessionUpdateDTO dtoUpdate)
        {
            TutoringSession old     = dtoUpdate.Old;
            TutoringSession updated = dtoUpdate.Updated;

            using (var context = new LabManagerDbContext())
            {
                TutoringSession dbTs = context.TutoringSession
                                       .Include(x => x.Tutors)
                                       .SingleOrDefault(x => x.Code.Equals(old.Code) && x.StartTime.Equals(old.StartTime) && x.EndTime.Equals(old.EndTime));
                if (dbTs == null)
                {
                    return;
                }

                List <TutorTutoringSession> addedSessions   = updated.Tutors.Except(dbTs.Tutors).ToList();
                List <TutorTutoringSession> deletedSessions = dbTs.Tutors.Except(updated.Tutors).ToList();

                using (var transaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        // Deleted entries
                        deletedSessions.ForEach(c => dbTs.Tutors.Remove(c));

                        if (!old.Equals(updated))
                        {
                            // Keys have been changed
                            context.TutoringSession.Remove(dbTs);
                            context.TutoringSession.Add(updated);
                        }
                        else if (!old.FullEquals(updated))
                        {
                            dbTs.NumberOfParticipants = updated.NumberOfParticipants;
                            foreach (TutorTutoringSession ptt in addedSessions)
                            {
                                object[] parameters = new object[4];
                                parameters[0] = new SqlParameter("@ssn", ptt.Ssn);
                                parameters[1] = new SqlParameter("@code", ptt.Code);
                                parameters[2] = new SqlParameter("@startTime", ptt.StartTime);
                                parameters[3] = new SqlParameter("@endTime", ptt.EndTime);

                                context.Database.ExecuteSqlCommand("EXEC dbo.TutorTutoringSession_Add @ssn, @code, @startTime, @endTime", parameters);
                            }
                        }
                        context.SaveChanges();

                        transaction.Commit();
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }
                }
            }
        }
Пример #6
0
 public TutoringSession GetTutoringSession(String code, DateTime startTime, DateTime endTime)
 {
     using (var context = new LabManagerDbContext())
     {
         TutoringSession dbTs = context.TutoringSession
                                .Include(x => x.Tutors)
                                .SingleOrDefault(x => x.Code.Equals(code) && x.StartTime.Equals(startTime) && x.EndTime.Equals(endTime));
         return(dbTs);
     }
 }
Пример #7
0
        private void BtnConfirmTutoringSessionsChanges_Click(object sender, RoutedEventArgs e)
        {
            Course   tmpCourse    = tvm.SelectedCourse;
            DateTime tmpStartDate = dtpStartTime.Value ?? default(DateTime);
            DateTime tmpEndDate   = dtpEndTime.Value ?? default(DateTime);



            TutoringSession tmpSession = new TutoringSession(tmpCourse.Code, tmpStartDate, tmpEndDate, iudParticipants.Value);

            tvm.UpdateTutoringSession(tmpSession);
            ToggleTutoringSessionsEditable(false);
        }
Пример #8
0
 public void DeleteTutoringSession(TutoringSession ts)
 {
     using (var context = new LabManagerDbContext())
     {
         TutoringSession dbTutoringSession = context.TutoringSession
                                             .Find(ts.Code, ts.StartTime, ts.EndTime);
         if (dbTutoringSession == null)
         {
             return;
         }
         context.TutoringSession.Remove(dbTutoringSession);
         context.SaveChanges();
     }
 }
Пример #9
0
            protected static void SectionC(ProjetContext appContext)
            {
                Tutor tutorUP = new Tutor();

                tutorUP = appContext.Tutor.Where(s => s.FirstName == "Gary" && s.LastName == "Bilodeau").FirstOrDefault <Tutor>();
                if (tutorUP != null)
                {
                    tutorUP.EmailAddress = "*****@*****.**";
                }
                HelpedStudent hsUP;

                hsUP = appContext.HelpedStudent.Where(hs => hs.FirstName == "Marc" && hs.LastName == "Arsenault").FirstOrDefault <HelpedStudent>();
                TutoringSession TutoringSessionHsUp = appContext.TutoringSession.Where(s => s.Id == hsUP.Id).FirstOrDefault();

                appContext.TutoringSession.Remove(TutoringSessionHsUp);
                appContext.HelpedStudent.Remove(hsUP);
                appContext.SaveChanges();
                HelpedStudent hsUP2;

                hsUP2 = appContext.HelpedStudent.Where(hs => hs.FirstName == "Marc" && hs.LastName == "Arsenault").FirstOrDefault <HelpedStudent>();
                TutoringSession TutoringSessionUP = new TutoringSession();

                TutoringSessionUP = appContext.TutoringSession.Where(ts => ts.Helped.Id == hsUP2.Id).FirstOrDefault <TutoringSession>();
                if (tutorUP != null)
                {
                    TutoringSessionUP.DateSession = new DateTime(2015, 04, 09, 11, 0, 0);
                    TutoringSessionUP.TimeSession = TimeSpan.FromHours(2);
                }
                appContext.SaveChanges();
                HelpedStudent HsJoin = new HelpedStudent();

                HsJoin = appContext.HelpedStudent.Where(hs => hs.FirstName == "Samuel" && hs.LastName == "Vachon").FirstOrDefault <HelpedStudent>();
                Tutor TutorJoin = new Tutor();

                TutorJoin = appContext.Tutor.Where(hs => hs.FirstName == "Louis" && hs.LastName == "Vézina").FirstOrDefault <Tutor>();

                TutoringSession newTutoringSession = new TutoringSession();

                newTutoringSession.DateSession   = new DateTime(2015, 06, 04, 10, 0, 0);
                newTutoringSession.TimeSession   = TimeSpan.FromHours(10);
                newTutoringSession.LengthSession = TimeSpan.FromHours(2);
                newTutoringSession.HelpedId      = HsJoin;
                newTutoringSession.TutorId       = TutorJoin;

                appContext.TutoringSession.Add(newTutoringSession);
                appContext.SaveChanges();
            }
Пример #10
0
        public async Task CreateTutoringSession(TutoringSessionNewDto tutoringSessionNew)
        {
            await ValidateSessionCreation(tutoringSessionNew);

            var tutoringSession = new TutoringSession
            {
                CreationDate = _timeService.GetCurrentTime(),
                IsSubscribed = tutoringSessionNew.IsSubscribed,
                ModuleId     = tutoringSessionNew.ModuleId,
                TutorId      = _currentUserService.GetUserId(),
                StudentId    = tutoringSessionNew.StudentId,
                SessionDate  = tutoringSessionNew.SessionDate,
                Status       = TutoringSessionStatusEnum.Upcoming
            };

            await _tutoringSessionsRepository.Create(tutoringSession);
        }
Пример #11
0
        public void DeleteTutoringSession(String code, DateTime startTime, DateTime endTime, int?participants)
        {
            TutoringSession tmpTs = new TutoringSession(code, startTime, endTime, participants);

            ICollection <TutoringSession> toBeDeleted = new List <TutoringSession>();

            foreach (TutoringSession ts in SelectedCourse.TutoringSessions)
            {
                if (ts.Equals(tmpTs))
                {
                    toBeDeleted.Add(ts);
                }
            }

            foreach (TutoringSession ts in toBeDeleted)
            {
                selectedCourse.TutoringSessions.Remove(ts);
            }

            try
            {
                dal.DeleteTutoringSession(tmpTs);

                TutoringSessions.Remove(tmpTs);
                //selectedCourse.TutoringSessions.Remove(SelectedTutoringSession);

                Status        = "Tutoring session was removed!";
                SelectedTutor = null;
            }
            catch (Exception ex)
            {
                // Rollback
                foreach (TutoringSession ts in toBeDeleted)
                {
                    selectedCourse.TutoringSessions.Add(ts);
                }
                Status = ExceptionHandler.GetErrorMessage(ex);
            }
            Courses = new ObservableCollection <Course>(dal.GetAllCourses());
            NotifyPropertyChanged("Courses");

            NotifyPropertyChanged("TutoringSessions");

            selectedCourse = Courses.FirstOrDefault(c => c.Code.Equals(code));
            NotifyPropertyChanged("SelectedCourse");
        }
Пример #12
0
        public void DeleteTutor(TutoringSession ts)
        {
            if (ts != null)
            {
                ICollection <TutorTutoringSession> tutorTutoringSessionsToBeDeleted = new List <TutorTutoringSession>();
                foreach (TutorTutoringSession tts in ts.Tutors)
                {
                    if (tts.Tutor.Equals(selectedTutor))
                    {
                        tutorTutoringSessionsToBeDeleted.Add(tts);
                    }
                }
                foreach (TutorTutoringSession tts in tutorTutoringSessionsToBeDeleted)
                {
                    ts.Tutors.Remove(tts);
                    selectedTutor.TutoringSessions.Remove(tts);
                }
                try
                {
                    TutoringSessionUpdateDTO updateDTO = new TutoringSessionUpdateDTO(ts, ts);
                    dal.UpdateTutoringSession(updateDTO);

                    Status = "Removed from planned sessions";
                }
                catch (Exception ex)
                {
                    // Rollback
                    foreach (TutorTutoringSession tts in ts.Tutors)
                    {
                        ts.Tutors.Add(tts);
                        selectedTutor.TutoringSessions.Add(tts);
                    }
                    Status = ExceptionHandler.GetErrorMessage(ex);
                }
                NotifyPropertyChanged("TutorTutoredHours");
                NotifyPropertyChanged("TutorPlannedHours");
                NotifyPropertyChanged("TutorLastSession");
                NotifyPropertyChanged("TutorNextSession");
                NotifyPropertyChanged("AvailableTutoringSessions");
                NotifyPropertyChanged("PlannedTutoringSessions");
            }
        }
Пример #13
0
        public void AddTutoringSession(String code, DateTime startTime, DateTime endTime)
        {
            try
            {
                TutoringSession ts = new TutoringSession(code, startTime, endTime, null);
                dal.AddTutoringSession(ts);
                TutoringSessions.Add(ts);

                TutoringSessions = new ObservableCollection <TutoringSession>(dal.GetAllTutoringSessions());
                NotifyPropertyChanged("TutoringSessions");

                Courses = new ObservableCollection <Course>(dal.GetAllCourses());
                NotifyPropertyChanged("Courses");

                Status        = "Tutoring session was added!";
                SelectedTutor = null;
            }
            catch (Exception ex)
            {
                Status = ExceptionHandler.GetErrorMessage(ex);
            }
        }
Пример #14
0
        public async Task CancelTutoringSession(int id, TutoringSessionCancelDto tutoringSessionCancel)
        {
            var session = await _tutoringSessionsRepository.GetById(id);

            var currentUserId = _currentUserService.GetUserId();

            if (session.TutorId != currentUserId && session.StudentId != currentUserId)
            {
                throw new InvalidOperationException("You can not cancel this session");
            }

            if (session.Status != TutoringSessionStatusEnum.Upcoming)
            {
                throw new InvalidOperationException("You can not cancel this session");
            }

            session.Status             = TutoringSessionStatusEnum.Cancelled;
            session.StatusChangeDate   = _timeService.GetCurrentTime();
            session.CancellationReason = tutoringSessionCancel.Reason;

            await _tutoringSessionsRepository.Update(session);

            if (session.IsSubscribed)
            {
                var newSession = new TutoringSession
                {
                    CreationDate = _timeService.GetCurrentTime(),
                    IsSubscribed = true,
                    ModuleId     = session.ModuleId,
                    SessionDate  = session.SessionDate.AddDays(7),
                    Status       = TutoringSessionStatusEnum.Upcoming,
                    StudentId    = session.StudentId,
                    TutorId      = session.TutorId
                };

                await _tutoringSessionsRepository.Create(newSession);
            }
        }
Пример #15
0
        private void BtnDeleteTutoringSession_Click(object sender, RoutedEventArgs e)
        {
            TutoringSession ts = (TutoringSession)lvTutoringSessions.SelectedItem;

            if (ts != null)
            {
                string sMessageBoxText = "Do you really want to remove " + tvm.SelectedTutoringSession.Code + "'s tutoring session on \n" + tvm.SelectedTutoringSession.StartTime + " -- " + tvm.SelectedTutoringSession.EndTime + " ?";
                string sCaption        = "Warning!";

                MessageBoxButton btnMessageBox = MessageBoxButton.YesNo;
                MessageBoxImage  icnMessageBox = MessageBoxImage.Warning;

                MessageBoxResult rsltMessageBox = MessageBox.Show(sMessageBoxText, sCaption, btnMessageBox, icnMessageBox);

                switch (rsltMessageBox)
                {
                case MessageBoxResult.Yes:

                    var code         = ts.Code;
                    var startTime    = ts.StartTime;
                    var endTime      = ts.EndTime;
                    var participants = ts.NumberOfParticipants;

                    tvm.DeleteTutoringSession(code, startTime, endTime, participants);

                    //lvTutoringSessions.GetBindingExpression(ListView.ItemsSourceProperty).UpdateTarget();
                    break;

                case MessageBoxResult.No:
                    /* ... */
                    break;
                }
            }
            else
            {
                tvm.Status = "You must select a Tutoring Session";
            }
        }
Пример #16
0
        private void ValidateSessionEvaluation(TutoringSession session)
        {
            var currentUserId = _currentUserService.GetUserId();

            if (session is null)
            {
                throw new InvalidOperationException("You can not evaluate this session: It does not exist.");
            }

            if (session.StudentId != currentUserId)
            {
                throw new InvalidOperationException("You can not evaluate this session: You are not the student.");
            }

            if (session.Status != TutoringSessionStatusEnum.Finished)
            {
                throw new InvalidOperationException("You can not evaluate this session: It's not finished yet");
            }

            if (session.Evaluation != null)
            {
                throw new InvalidOperationException("You can not evaluate this session: It has been evaluated already.");
            }
        }
Пример #17
0
 public Decimal GetStudentsPerTutorRatio(TutoringSession ts)
 {
     return(GetStudentsPerTutorRatio(ts.Code, ts.StartTime, ts.EndTime));
 }
 public TutoringSessionUpdateDTO(TutoringSession old, TutoringSession updated)
 {
     this.old     = new TutoringSession(old.Code, old.StartTime, old.EndTime, 0);
     this.updated = updated;
 }
Пример #19
0
    static void Main(string[] args)
    {
        Console.WriteLine("Pour voir les entrées des 3 tables appuyez sur 0,");
        Console.WriteLine("Pour voir la requête 1 appuyez sur 1,");
        Console.WriteLine("Pour voir la requête 2 appuyez sur 2,");
        Console.WriteLine("Pour voir la requête 3 appuyez sur 3,");
        Console.WriteLine("Pour voir la requête 4 appuyez sur 4,");
        Console.WriteLine("Pour peupler les tables appuyez sur 5 :");

        string resultat = Console.ReadLine();

        if (resultat == "0")
        {
            var context = new TutoratDbContext();

            var query =
                from tutor in context.Tutors
                from helped in context.HelpedStudents
                from sessions in context.TutoringSessions
                select new
            {
                TutorID          = tutor.Id,
                TutorLastName    = tutor.LastName,
                TutorFirstName   = tutor.FirstName,
                TutorEmailAdress = tutor.EmailAdress,

                HelpedID          = helped.Id,
                HelpedLastName    = helped.LastName,
                HelpedFirstName   = helped.FirstName,
                HelpedEmailAdress = helped.EmailAdress,

                SessionsId       = sessions.Id,
                SessionsTutorId  = sessions.TutorId,
                SessionsHelpedId = sessions.HelpedId,
                SessionsTime     = sessions.DateTimeSession,
                SessionsLenght   = sessions.LenghtSession
            };
            foreach (var tuteurs in query)
            {
                Console.WriteLine("TutorID : {0} Name : {1} {2} Email Adress : {3}",
                                  tuteurs.TutorID, tuteurs.TutorFirstName, tuteurs.TutorLastName, tuteurs.TutorEmailAdress);
            }
            foreach (var helped in query)
            {
                Console.WriteLine("HelpedID : {0} Name : {1} {2} Email Adress : {3}",
                                  helped.HelpedID, helped.HelpedFirstName, helped.HelpedLastName, helped.HelpedEmailAdress);
            }
            foreach (var session in query)
            {
                Console.WriteLine("SessionID : {0} TutorId : {1} HelpedId : {2} Time : {3} Lenght Session : {4}",
                                  session.SessionsId, session.SessionsTutorId, session.SessionsHelpedId, session.SessionsTime, session.SessionsLenght);
            }
            Console.ReadLine();
        }
        else if (resultat == "1")
        {
            TutorController controller = new TutorController();
            controller.AfficherListeTuteurs();
        }
        else if (resultat == "4")
        {
            TutorController controller = new TutorController();
            controller.AfficherListTuteurs2Juin();
        }
        else if (resultat == "5")
        {
            var contextTutor = new EfEntityRepository <Tutor>();

            var tutorGB = new Tutor();
            tutorGB.LastName    = "Bilodeau";
            tutorGB.FirstName   = "Gary";
            tutorGB.EmailAdress = "*****@*****.**";
            contextTutor.Add(tutorGB);

            var tutorSG = new Tutor();
            tutorSG.LastName    = "Gagnon";
            tutorSG.FirstName   = "Samuel";
            tutorSG.EmailAdress = "*****@*****.**";
            contextTutor.Add(tutorSG);

            var tutorSimG = new Tutor();
            tutorSimG.LastName    = "Gingras";
            tutorSimG.FirstName   = "Simon";
            tutorSimG.EmailAdress = "*****@*****.**";
            contextTutor.Add(tutorSimG);

            var tutorER = new Tutor();
            tutorER.LastName    = "Roy";
            tutorER.FirstName   = "Éric";
            tutorER.EmailAdress = "*****@*****.**";
            contextTutor.Add(tutorER);

            var tutorCV = new Tutor();
            tutorCV.LastName    = "Veilleux";
            tutorCV.FirstName   = "Caroline";
            tutorCV.EmailAdress = "*****@*****.**";
            contextTutor.Add(tutorCV);

            var tutorKT = new Tutor();
            tutorKT.LastName    = "Tremblay";
            tutorKT.FirstName   = "Karine";
            tutorKT.EmailAdress = "*****@*****.**";
            contextTutor.Add(tutorKT);

            var tutorLV = new Tutor();
            tutorLV.LastName    = "Vézina";
            tutorLV.FirstName   = "Louis";
            tutorLV.EmailAdress = "*****@*****.**";
            contextTutor.Add(tutorLV);


            var contextHelpedStudent = new EfEntityRepository <HelpedStudent>();

            var helpedMA = new HelpedStudent();
            helpedMA.LastName    = "Arsenault";
            helpedMA.FirstName   = "Marc";
            helpedMA.EmailAdress = "*****@*****.**";
            contextHelpedStudent.Add(helpedMA);

            var helpedEB = new HelpedStudent();
            helpedEB.LastName    = "Boilard";
            helpedEB.FirstName   = "Éric";
            helpedEB.EmailAdress = "*****@*****.**";
            contextHelpedStudent.Add(helpedEB);

            var helpedJCC = new HelpedStudent();
            helpedJCC.LastName    = "Couture";
            helpedJCC.FirstName   = "Jean-Christophe";
            helpedJCC.EmailAdress = "*****@*****.**";
            contextHelpedStudent.Add(helpedJCC);

            var helpedJD = new HelpedStudent();
            helpedJD.LastName    = "Desrosiers";
            helpedJD.FirstName   = "Julianne";
            helpedJD.EmailAdress = "*****@*****.**";
            contextHelpedStudent.Add(helpedJD);

            var helpedLGA = new HelpedStudent();
            helpedLGA.LastName    = "Grégoire-Allen";
            helpedLGA.FirstName   = "Léo";
            helpedLGA.EmailAdress = "*****@*****.**";
            contextHelpedStudent.Add(helpedLGA);

            var helpedFH = new HelpedStudent();
            helpedFH.LastName    = "Hamel";
            helpedFH.FirstName   = "François";
            helpedFH.EmailAdress = "*****@*****.**";
            contextHelpedStudent.Add(helpedFH);

            var helpedJL = new HelpedStudent();
            helpedJL.LastName    = "Lepage";
            helpedJL.FirstName   = "Jérémy";
            helpedJL.EmailAdress = "*****@*****.**";
            contextHelpedStudent.Add(helpedJL);

            var helpedNP = new HelpedStudent();
            helpedNP.LastName    = "Poitras";
            helpedNP.FirstName   = "Nicolas";
            helpedNP.EmailAdress = "*****@*****.**";
            contextHelpedStudent.Add(helpedNP);

            var helpedSRG = new HelpedStudent();
            helpedSRG.LastName    = "Roy-Gagnon";
            helpedSRG.FirstName   = "Samuel";
            helpedSRG.EmailAdress = "*****@*****.**";
            contextHelpedStudent.Add(helpedSRG);

            var helpedBS = new HelpedStudent();
            helpedBS.LastName    = "Simard";
            helpedBS.FirstName   = "Benjamin";
            helpedBS.EmailAdress = "*****@*****.**";
            contextHelpedStudent.Add(helpedBS);

            var helpedSV = new HelpedStudent();
            helpedSV.LastName    = "Vachon";
            helpedSV.FirstName   = "Samuel";
            helpedSV.EmailAdress = "*****@*****.**";
            contextHelpedStudent.Add(helpedSV);


            var contextSessions = new EfEntityRepository <TutoringSession>();

            var session = new TutoringSession();
            session.DateTimeSession = new DateTime(2015, 03, 16, 13, 00, 00);
            session.LenghtSession   = 2;
            session.Helped          = helpedLGA;
            session.HelpedId        = helpedLGA.Id;
            session.Tutor           = tutorCV;
            session.TutorId         = tutorCV.Id;
            contextSessions.Add(session);

            var session1 = new TutoringSession();
            session1.DateTimeSession = new DateTime(2015, 03, 24, 10, 00, 00);
            session1.LenghtSession   = 1;
            session1.Helped          = helpedLGA;
            session1.HelpedId        = helpedLGA.Id;
            session1.Tutor           = tutorGB;
            session1.TutorId         = tutorGB.Id;
            contextSessions.Add(session1);

            var session2 = new TutoringSession();
            session2.DateTimeSession = new DateTime(2015, 03, 25, 13, 00, 00);
            session2.LenghtSession   = 1;
            session2.Helped          = helpedEB;
            session2.HelpedId        = helpedEB.Id;
            session2.Tutor           = tutorER;
            session2.TutorId         = tutorER.Id;
            contextSessions.Add(session2);

            var session3 = new TutoringSession();
            session3.DateTimeSession = new DateTime(2015, 04, 01, 12, 00, 00);
            session3.LenghtSession   = 2;
            session3.Helped          = helpedMA;
            session3.HelpedId        = helpedMA.Id;
            session3.Tutor           = tutorCV;
            session3.TutorId         = tutorCV.Id;
            contextSessions.Add(session3);

            var session4 = new TutoringSession();
            session4.DateTimeSession = new DateTime(2015, 04, 01, 13, 00, 00);
            session4.LenghtSession   = 1;
            session4.Helped          = helpedEB;
            session4.HelpedId        = helpedEB.Id;
            session4.Tutor           = tutorSG;
            session4.TutorId         = tutorSG.Id;
            contextSessions.Add(session4);

            var session5 = new TutoringSession();
            session5.DateTimeSession = new DateTime(2015, 04, 06, 16, 00, 00);
            session5.LenghtSession   = 1;
            session5.Helped          = helpedMA;
            session5.HelpedId        = helpedMA.Id;
            session5.Tutor           = tutorER;
            session5.TutorId         = tutorER.Id;
            contextSessions.Add(session5);

            var session6 = new TutoringSession();
            session6.DateTimeSession = new DateTime(2015, 04, 08, 10, 00, 00);
            session6.LenghtSession   = 1;
            session6.Helped          = helpedFH;
            session6.HelpedId        = helpedFH.Id;
            session6.Tutor           = tutorER;
            session6.TutorId         = tutorER.Id;
            contextSessions.Add(session6);

            var session7 = new TutoringSession();
            session7.DateTimeSession = new DateTime(2015, 04, 10, 10, 00, 00);
            session7.LenghtSession   = 2;
            session7.Helped          = helpedMA;
            session7.HelpedId        = helpedMA.Id;
            session7.Tutor           = tutorER;
            session7.TutorId         = tutorER.Id;
            contextSessions.Add(session7);

            var session8 = new TutoringSession();
            session8.DateTimeSession = new DateTime(2015, 04, 29, 12, 00, 00);
            session8.LenghtSession   = 1;
            session8.Helped          = helpedSRG;
            session8.HelpedId        = helpedSRG.Id;
            session8.Tutor           = tutorCV;
            session8.TutorId         = tutorCV.Id;
            contextSessions.Add(session8);

            var session9 = new TutoringSession();
            session9.DateTimeSession = new DateTime(2015, 05, 25, 13, 00, 00);
            session9.LenghtSession   = 1;
            session9.Helped          = helpedBS;
            session9.HelpedId        = helpedBS.Id;
            session9.Tutor           = tutorLV;
            session9.TutorId         = tutorLV.Id;
            contextSessions.Add(session9);

            var session10 = new TutoringSession();
            session10.DateTimeSession = new DateTime(2015, 05, 27, 12, 00, 00);
            session10.LenghtSession   = 2;
            session10.Helped          = helpedBS;
            session10.HelpedId        = helpedBS.Id;
            session10.Tutor           = tutorCV;
            session10.TutorId         = tutorCV.Id;
            contextSessions.Add(session10);

            var session11 = new TutoringSession();
            session11.DateTimeSession = new DateTime(2015, 05, 27, 13, 00, 00);
            session11.LenghtSession   = 1;
            session11.Helped          = helpedEB;
            session11.HelpedId        = helpedEB.Id;
            session11.Tutor           = tutorSimG;
            session11.TutorId         = tutorSimG.Id;
            contextSessions.Add(session11);

            var session12 = new TutoringSession();
            session12.DateTimeSession = new DateTime(2015, 06, 01, 9, 00, 00);
            session12.LenghtSession   = 1;
            session12.Helped          = helpedJL;
            session12.HelpedId        = helpedJL.Id;
            session12.Tutor           = tutorLV;
            session12.TutorId         = tutorLV.Id;
            contextSessions.Add(session12);

            var session13 = new TutoringSession();
            session13.DateTimeSession = new DateTime(2015, 06, 02, 9, 00, 00);
            session13.LenghtSession   = 1;
            session13.Helped          = helpedSV;
            session13.HelpedId        = helpedSV.Id;
            session13.Tutor           = tutorLV;
            session13.TutorId         = tutorLV.Id;
            contextSessions.Add(session13);

            var session14 = new TutoringSession();
            session14.DateTimeSession = new DateTime(2015, 06, 02, 11, 00, 00);
            session14.LenghtSession   = 1;
            session14.Helped          = helpedEB;
            session14.HelpedId        = helpedEB.Id;
            session14.Tutor           = tutorLV;
            session14.TutorId         = tutorLV.Id;
            contextSessions.Add(session14);

            var session15 = new TutoringSession();
            session15.DateTimeSession = new DateTime(2015, 06, 02, 13, 00, 00);
            session15.LenghtSession   = 1;
            session15.Helped          = helpedLGA;
            session15.HelpedId        = helpedLGA.Id;
            session15.Tutor           = tutorGB;
            session15.TutorId         = tutorGB.Id;
            contextSessions.Add(session15);

            var session16 = new TutoringSession();
            session16.DateTimeSession = new DateTime(2015, 06, 02, 15, 00, 00);
            session16.LenghtSession   = 1;
            session16.Helped          = helpedSRG;
            session16.HelpedId        = helpedSRG.Id;
            session16.Tutor           = tutorER;
            session16.TutorId         = tutorER.Id;
            contextSessions.Add(session16);

            var session17 = new TutoringSession();
            session17.DateTimeSession = new DateTime(2015, 06, 03, 13, 00, 00);
            session17.LenghtSession   = 2;
            session17.Helped          = helpedJL;
            session17.HelpedId        = helpedJL.Id;
            session17.Tutor           = tutorSimG;
            session17.TutorId         = tutorSimG.Id;
            contextSessions.Add(session17);

            Console.WriteLine("Tables correctement peuplées");
        }

        Console.ReadLine();
    }
Пример #20
0
        public static void Main(string[] args)
        {
            Stopwatch stopWatch = new Stopwatch();

            DAL dal = new DAL();

            dal.GetAllCourses();


            DateTime startTime = new DateTime(2017, 10, 04, 15, 00, 00);
            DateTime endTime   = new DateTime(2017, 10, 04, 18, 00, 00);

            //Random r = new Random();
            //Course testCourse = new Course(r.Next(65535).ToString(), "testname", 10M, 10);

            //dal.AddCourse(testCourse);

            //DateTime tsOldStartTime1 = new DateTime(2017, 10, 04, 08, 00, 00);
            //DateTime tsOldEndTime1 = new DateTime(2017, 10, 04, 10, 00, 00);

            //TutoringSession ts = dal.GetTutoringSession("INFC20", tsOldStartTime1, tsOldEndTime1);

            //Console.WriteLine(dal.GetStudentsPerTutorRatio(ts.Code, ts.StartTime, ts.EndTime));

            //Console.WriteLine(dal.GetNumberOfTutors(ts.Code, ts.StartTime, ts.EndTime));

            //Console.WriteLine(dal.GetTutorTutoringSessionHours("111"));

            //Tutor t1 = dal.GetTutor("111");
            //List<TutoringSession> t2 = dal.GetAllTutoringSessions();

            //IEnumerable<TutoringSession> t1Tutoring = t1.TutoringSessions.Select(x => x.TutoringSession);

            ////IEnumerable<TutoringSession> tss2 = t2;

            //IEnumerable<TutoringSession> availableSessions = t2.Except(t1Tutoring);

            //Console.WriteLine("Handledare " + t1.FullName + " har dessa pass lediga: ");
            //foreach (TutoringSession ts in availableSessions)
            //{
            //    Console.WriteLine(ts.Code + " " + ts.StartTime + " " + ts.EndTime);
            //}


            //DateTime tsStartTime = new DateTime(2017, 10, 04, 09, 00, 00);
            //DateTime tsEndTime = new DateTime(2017, 10, 04, 10, 00, 00);

            //TutoringSession ts = new TutoringSession("INFC94", tsStartTime, tsEndTime, 50);

            //try
            //{
            //    dal.AddTutoringSession(ts);
            //}

            //catch (Exception ex)
            //{
            //   String message = ExceptionHandler.GetErrorMessage(ex);
            //    Console.WriteLine(message);
            //}

            TutoringSession ts = new TutoringSession("INFC25", startTime, endTime, 10);

            //try
            //{
            //    dal.AddTutoringSession(ts);
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine(ExceptionHandler.GetErrorMessage(ex));
            //}

            //stopWatch.Start();
            //Course c1 = dal.GetCourse("INFC20");
            ////c1.Name = "HEJSAN";
            ////dal.UpdateCourse(c1);
            ////stopWatch.Stop();
            ////Console.WriteLine(stopWatch.ElapsedMilliseconds);

            //stopWatch = new Stopwatch();
            //stopWatch.Start();
            //dal.DeleteCourse(c1);

            //stopWatch.Stop();
            //Console.WriteLine(stopWatch.ElapsedMilliseconds);

            //stopWatch = new Stopwatch();
            //stopWatch.Start();
            //dal.GetAllTutors();
            //stopWatch.Stop();
            //Console.WriteLine(stopWatch.ElapsedMilliseconds);

            //Tutor t2 = new Tutor("666", "firstname", "lastname", "*****@*****.**", "pass");

            //stopWatch = new Stopwatch();
            //stopWatch.Start();
            //stopWatch.Stop();
            //Console.WriteLine(stopWatch.ElapsedMilliseconds);

            //dal.AddTutoringSession(ts);

            TutoringSession ts2 = dal.GetTutoringSession("INFC25", ts.StartTime, ts.EndTime);

            ts2.EndTime = new DateTime(2017, 10, 04, 19, 00, 00);

            stopWatch = new Stopwatch();
            stopWatch.Start();
            dal.UpdateTutoringSession(new TutoringSessionUpdateDTO(ts, ts2));
            stopWatch.Stop();
            Console.WriteLine(stopWatch.ElapsedMilliseconds);

            Console.ReadKey();
        }
Пример #21
0
        public async Task RecheckUpcomingTutoringSessions()
        {
            var currentTime = _timeService.GetCurrentTime();
            var sessions    = await _tutoringSessionsRepository.GetFiltered(ts => ts.Status == TutoringSessionStatusEnum.Upcoming);

            foreach (var session in sessions)
            {
                var timeDifference = session.SessionDate - currentTime;

                if (timeDifference.TotalMinutes < -30)
                {
                    session.Status           = TutoringSessionStatusEnum.Finished;
                    session.StatusChangeDate = currentTime;
                    await _tutoringSessionsRepository.Update(session);

                    var studentNotification = new TutoringSessionFinishedNotificationDto {
                        SessionId = session.Id, ParticipantId = session.TutorId, TutorName = session.Tutor.FirstName + " " + session.Tutor.LastName, OpenNotificationDialog = true
                    };
                    var tutorNotification = new TutoringSessionFinishedNotificationDto {
                        ParticipantId = session.StudentId
                    };
                    await _hubsService.SendSessionFinishedNotificationToUser(session.StudentId, studentNotification);

                    await _hubsService.SendSessionFinishedNotificationToUser(session.TutorId, tutorNotification);

                    if (session.IsSubscribed)
                    {
                        var newSession = new TutoringSession
                        {
                            CreationDate = currentTime,
                            IsSubscribed = true,
                            ModuleId     = session.ModuleId,
                            SessionDate  = session.SessionDate.AddDays(7),
                            Status       = TutoringSessionStatusEnum.Upcoming,
                            StudentId    = session.StudentId,
                            TutorId      = session.TutorId
                        };

                        await _tutoringSessionsRepository.Create(newSession);
                    }
                }
                else if (timeDifference.TotalMinutes < 15 && !session.IsReminderSent)
                {
                    await _emailService.SendTutoringSessionReminder(session.Tutor.Email);

                    await _emailService.SendTutoringSessionReminder(session.Student.Email);

                    session.IsReminderSent = true;
                    await _tutoringSessionsRepository.Update(session);
                }
                else if (timeDifference.TotalMinutes < 0)
                {
                    var studentNotification = new TutoringSessionOnGoingDto
                    {
                        ModuleId      = session.ModuleId,
                        ParticipantId = session.TutorId,
                        IsStudent     = true
                    };
                    await _hubsService.SendSessionOnGoingNotificationToUser(session.StudentId, studentNotification);

                    var tutorNotification = new TutoringSessionOnGoingDto
                    {
                        ModuleId      = session.ModuleId,
                        ParticipantId = session.StudentId
                    };
                    await _hubsService.SendSessionOnGoingNotificationToUser(session.TutorId, tutorNotification);
                }
            }
        }
Пример #22
0
        protected override void Seed(SinapseContext appContext)
        {
            base.Seed(appContext);
            Tutor tut1 = new Tutor()
            {
                ID = 100, LastName = "Bilodeau", FirstName = "Gary", EmailAddress = "*****@*****.**"
            };
            Tutor tut2 = new Tutor()
            {
                ID = 101, LastName = "Gagnon", FirstName = "Samuel", EmailAddress = "*****@*****.**"
            };
            Tutor tut3 = new Tutor()
            {
                ID = 102, LastName = "Gingras", FirstName = "Simon", EmailAddress = "*****@*****.**"
            };
            Tutor tut4 = new Tutor()
            {
                ID = 103, LastName = "Roy", FirstName = "Éric", EmailAddress = "*****@*****.**"
            };
            Tutor tut5 = new Tutor()
            {
                ID = 104, LastName = "Veilleux", FirstName = "Caroline", EmailAddress = "*****@*****.**"
            };
            Tutor tut6 = new Tutor()
            {
                ID = 105, LastName = "Tremblay", FirstName = "Karine", EmailAddress = "*****@*****.**"
            };
            Tutor tut7 = new Tutor()
            {
                ID = 106, LastName = "Vézina", FirstName = "Louis", EmailAddress = "*****@*****.**"
            };

            appContext.Tutors.Add(tut1);
            appContext.Tutors.Add(tut2);
            appContext.Tutors.Add(tut3);
            appContext.Tutors.Add(tut4);
            appContext.Tutors.Add(tut5);
            appContext.Tutors.Add(tut6);
            appContext.Tutors.Add(tut7);

            HelpedStudent stu1 = new HelpedStudent()
            {
                ID = 100, LastName = "Arsenault", FirstName = "Marc", EmailAddress = "*****@*****.**"
            };
            HelpedStudent stu2 = new HelpedStudent()
            {
                ID = 101, LastName = "Boilard", FirstName = "Eric", EmailAddress = "*****@*****.**"
            };
            HelpedStudent stu3 = new HelpedStudent()
            {
                ID = 102, LastName = "Couture", FirstName = "Jean-Cristophe", EmailAddress = "*****@*****.**"
            };
            HelpedStudent stu4 = new HelpedStudent()
            {
                ID = 103, LastName = "Desrosiers", FirstName = "Julianne", EmailAddress = "*****@*****.**"
            };
            HelpedStudent stu5 = new HelpedStudent()
            {
                ID = 104, LastName = "Grégoire-Allen", FirstName = "Léo", EmailAddress = "*****@*****.**"
            };
            HelpedStudent stu6 = new HelpedStudent()
            {
                ID = 105, LastName = "Hamel", FirstName = "François", EmailAddress = "*****@*****.**"
            };
            HelpedStudent stu7 = new HelpedStudent()
            {
                ID = 106, LastName = "Lepage", FirstName = "Jérémy", EmailAddress = "*****@*****.**"
            };
            HelpedStudent stu8 = new HelpedStudent()
            {
                ID = 107, LastName = "Poitras", FirstName = "Nicolas", EmailAddress = "*****@*****.**"
            };
            HelpedStudent stu9 = new HelpedStudent()
            {
                ID = 108, LastName = "Roy-Gagnon", FirstName = "Samuel", EmailAddress = "*****@*****.**"
            };
            HelpedStudent stu10 = new HelpedStudent()
            {
                ID = 109, LastName = "Simard", FirstName = "Benjamin", EmailAddress = "*****@*****.**"
            };
            HelpedStudent stu11 = new HelpedStudent()
            {
                ID = 110, LastName = "Vachon", FirstName = "Samuel", EmailAddress = "*****@*****.**"
            };

            appContext.HelpedStudents.Add(stu1);
            appContext.HelpedStudents.Add(stu2);
            appContext.HelpedStudents.Add(stu3);
            appContext.HelpedStudents.Add(stu4);
            appContext.HelpedStudents.Add(stu5);
            appContext.HelpedStudents.Add(stu6);
            appContext.HelpedStudents.Add(stu7);
            appContext.HelpedStudents.Add(stu8);
            appContext.HelpedStudents.Add(stu9);
            appContext.HelpedStudents.Add(stu10);
            appContext.HelpedStudents.Add(stu11);

            TutoringSession tgs1 = new TutoringSession()
            {
                ID = 100, DateSession = new DateTime(2015, 03, 16), TimeSession = 13, LengthSession = 2, HelpedID = stu5, TutorID = tut5
            };
            TutoringSession tgs2 = new TutoringSession()
            {
                ID = 101, DateSession = new DateTime(2015, 03, 24), TimeSession = 10, LengthSession = 1, HelpedID = stu5, TutorID = tut1
            };
            TutoringSession tgs3 = new TutoringSession()
            {
                ID = 102, DateSession = new DateTime(2015, 03, 25), TimeSession = 13, LengthSession = 1, HelpedID = stu2, TutorID = tut4
            };
            TutoringSession tgs4 = new TutoringSession()
            {
                ID = 103, DateSession = new DateTime(2015, 04, 01), TimeSession = 12, LengthSession = 2, HelpedID = stu1, TutorID = tut5
            };
            TutoringSession tgs5 = new TutoringSession()
            {
                ID = 104, DateSession = new DateTime(2015, 04, 01), TimeSession = 13, LengthSession = 1, HelpedID = stu2, TutorID = tut3
            };
            TutoringSession tgs6 = new TutoringSession()
            {
                ID = 105, DateSession = new DateTime(2015, 04, 06), TimeSession = 16, LengthSession = 1, HelpedID = stu1, TutorID = tut4
            };
            TutoringSession tgs7 = new TutoringSession()
            {
                ID = 106, DateSession = new DateTime(2015, 04, 08), TimeSession = 10, LengthSession = 1, HelpedID = stu6, TutorID = tut4
            };
            TutoringSession tgs8 = new TutoringSession()
            {
                ID = 107, DateSession = new DateTime(2015, 04, 10), TimeSession = 10, LengthSession = 2, HelpedID = stu1, TutorID = tut4
            };
            TutoringSession tgs9 = new TutoringSession()
            {
                ID = 108, DateSession = new DateTime(2015, 04, 29), TimeSession = 12, LengthSession = 1, HelpedID = stu9, TutorID = tut5
            };
            TutoringSession tgs10 = new TutoringSession()
            {
                ID = 109, DateSession = new DateTime(2015, 05, 25), TimeSession = 13, LengthSession = 1, HelpedID = stu10, TutorID = tut7
            };
            TutoringSession tgs11 = new TutoringSession()
            {
                ID = 110, DateSession = new DateTime(2015, 05, 27), TimeSession = 12, LengthSession = 2, HelpedID = stu10, TutorID = tut5
            };
            TutoringSession tgs12 = new TutoringSession()
            {
                ID = 111, DateSession = new DateTime(2015, 05, 27), TimeSession = 13, LengthSession = 1, HelpedID = stu2, TutorID = tut3
            };
            TutoringSession tgs13 = new TutoringSession()
            {
                ID = 112, DateSession = new DateTime(2015, 06, 01), TimeSession = 9, LengthSession = 1, HelpedID = stu7, TutorID = tut7
            };
            TutoringSession tgs14 = new TutoringSession()
            {
                ID = 113, DateSession = new DateTime(2015, 06, 02), TimeSession = 9, LengthSession = 1, HelpedID = stu11, TutorID = tut7
            };
            TutoringSession tgs15 = new TutoringSession()
            {
                ID = 114, DateSession = new DateTime(2015, 06, 02), TimeSession = 11, LengthSession = 1, HelpedID = stu2, TutorID = tut7
            };
            TutoringSession tgs16 = new TutoringSession()
            {
                ID = 115, DateSession = new DateTime(2015, 06, 02), TimeSession = 13, LengthSession = 1, HelpedID = stu5, TutorID = tut1
            };
            TutoringSession tgs17 = new TutoringSession()
            {
                ID = 116, DateSession = new DateTime(2015, 06, 02), TimeSession = 15, LengthSession = 1, HelpedID = stu9, TutorID = tut4
            };
            TutoringSession tgs18 = new TutoringSession()
            {
                ID = 117, DateSession = new DateTime(2015, 06, 03), TimeSession = 13, LengthSession = 2, HelpedID = stu7, TutorID = tut3
            };

            appContext.TutoringSessions.Add(tgs1);
            appContext.TutoringSessions.Add(tgs2);
            appContext.TutoringSessions.Add(tgs3);
            appContext.TutoringSessions.Add(tgs4);
            appContext.TutoringSessions.Add(tgs5);
            appContext.TutoringSessions.Add(tgs6);
            appContext.TutoringSessions.Add(tgs7);
            appContext.TutoringSessions.Add(tgs8);
            appContext.TutoringSessions.Add(tgs9);
            appContext.TutoringSessions.Add(tgs10);
            appContext.TutoringSessions.Add(tgs11);
            appContext.TutoringSessions.Add(tgs12);
            appContext.TutoringSessions.Add(tgs13);
            appContext.TutoringSessions.Add(tgs14);
            appContext.TutoringSessions.Add(tgs15);
            appContext.TutoringSessions.Add(tgs16);
            appContext.TutoringSessions.Add(tgs17);
            appContext.TutoringSessions.Add(tgs18);
        }
Пример #23
0
        private void BtnAddToPlannedSessions_Click(object sender, RoutedEventArgs e)
        {
            TutoringSession tmpTs = (TutoringSession)dgAvailableSessions.SelectedItem;

            tvm.AddTutor(tmpTs);
        }
Пример #24
0
 public int GetNumberOfTutors(TutoringSession ts)
 {
     return(GetNumberOfTutors(ts.Code, ts.StartTime, ts.EndTime));
 }