Пример #1
0
        public void RemoveDemoEntities()
        {
            if (DemoSessionId != -1)
            {
                _sessionDao.Remove(DemoSessionId);
            }

            if (!string.IsNullOrEmpty(DemoClassroomId))
            {
                _classroomDao.Remove(DemoClassroomId);
            }

            if (!string.IsNullOrEmpty(DemoSubjectId))
            {
                _subjectDao.Remove(DemoSubjectId);
            }

            if (!string.IsNullOrEmpty(DemoSoftwareId))
            {
                _softwareDao.Remove(DemoSoftwareId);
            }

            if (!string.IsNullOrEmpty(DemoCourseId))
            {
                _courseDao.Remove(DemoCourseId);
            }

            if (!string.IsNullOrEmpty(DemoScheduleId))
            {
                _scheduleDao.Remove(DemoScheduleId);
            }

            ResetDemoIds();
        }
        public Subject SaveSubject()
        {
            Subject.RequiredSoftware = new List <Software>();
            foreach (var softwareViewModel in SoftwareList)
            {
                if (softwareViewModel.IsChecked)
                {
                    Subject.RequiredSoftware.Add(softwareViewModel.Software);
                }
            }

            if (_adding)
            {
                SubjectDao.Add(Subject);
            }
            else
            {
                var subject = SubjectDao.FindById(Subject.Id);
                subject.Update(Subject);

                var sessions = SessionDao.GetIncompatibleSessions(subject);
                if (sessions.Count > 0)
                {
                    var dialog = new ConfirmDelete(sessions,
                                                   "Are you sure you want to update this subject? Some of the sessions have already been placed in the schedule. Following is the list of all sessions that will be deleted if you proceed with this update.")
                    {
                        HelpState = Constants.ApplicationState.SubjectsAdd
                    };
                    dialog.ShowDialog();

                    if (dialog.Confirm)
                    {
                        SubjectDao.Update(subject);
                        foreach (var session in sessions)
                        {
                            SessionDao.Remove(session.Id);
                        }

                        _mainWindowViewModel.InitRemainigSessions();
                        _mainWindowViewModel.InitSessions();
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    SubjectDao.Update(subject);
                    _mainWindowViewModel.InitRemainigSessions();
                    _mainWindowViewModel.InitSessions();
                }
            }

            return(Subject);
        }
Пример #3
0
        public Classroom SaveClassroom()
        {
            Classroom.InstalledSoftware = new List <Software>();
            foreach (var softwareViewModel in SoftwareList)
            {
                if (softwareViewModel.IsChecked)
                {
                    Classroom.InstalledSoftware.Add(softwareViewModel.Software);
                }
            }

            if (_adding)
            {
                ClassroomDao.Add(Classroom);
            }
            else
            {
                var sessions = SessionDao.GetIncompatibleSessions(Classroom);

                if (sessions.Count > 0)
                {
                    var dialog = new ConfirmDelete(sessions,
                                                   "Are you sure you want to update this classroom? Conflicting sessions have been found in the schedule. Following is the list of all sessions that will be deleted if you proceed with this update.")
                    {
                        HelpState = Constants.ApplicationState.ClassroomsAdd
                    };
                    dialog.ShowDialog();

                    if (dialog.Confirm)
                    {
                        ClassroomDao.Update(Classroom);
                        foreach (var session in sessions)
                        {
                            SessionDao.Remove(session.Id);
                        }

                        _mainWindowViewModel.InitRemainigSessions();
                        _mainWindowViewModel.InitSessions();
                    }
                }
                else
                {
                    ClassroomDao.Update(Classroom);
                    _mainWindowViewModel.InitRemainigSessions();
                    _mainWindowViewModel.InitSessions();
                }
            }

            return(Classroom);
        }
 public void DeleteSession()
 {
     SessionDao.Remove(Session.Id);
 }
 public void RemoveSession(Session session)
 {
     SessionDao.Remove(session.Id);
 }