コード例 #1
0
 private void AddSession()
 {
     if (MessageBox.Show("Are you sure", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         var sessions = SessionService.GetAllSessions().Where(d => d.CourseId == SelectedCourse.Id);
         if (ScheduleConflict(sessions))
         {
             //if Session Start is within Start and End of existing session for the same course - there is a schedule conflict and the operation must not be allowed
             MessageBox.Show("Schedule Conflict");
             return;
         }
         //create location from strings
         var address = AddressService.AddAddress(new Address()
         {
             ZipCode = VenueAddress,
         });
         var location = LocationService.AddLocation(new Location()
         {
             Address  = address,
             Capacity = VenueCapacity
         });
         Session = SessionService.AddSession(Session);
         var sessionLocation = SessionLocationService.Add(new Session_Location()
         {
             Session  = Session,
             Location = location
         });
         BackProc();
     }
 }
コード例 #2
0
        private void DeleteCourseProc()
        {
            if (MessageBox.Show("Are you sure?", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                //remove course
                //remove session
                //remove candidatesession
                //remove sessionlocation
                //remove qualificationsdevelopedbycourse
                //remove prerequisitesforcourse
                foreach (var v in CandidateSessionService.GetAll().Where(d => d.Session.CourseId == Course.Id))
                {
                    CandidateSessionService.Remove(v.CandidateId, v.SessionId);
                }

                foreach (var v in SessionService.GetAllSessions().Where(d => d.CourseId == Course.Id))
                {
                    SessionService.RemoveSession(v);
                }

                foreach (var v in SessionLocationService.GetAll().Where(d => d.Session.CourseId == Course.Id))
                {
                    SessionLocationService.Remove(v.SessionId, v.LocationId);
                }

                foreach (var v in SessionLocationService.GetAll().Where(d => d.Session.CourseId == Course.Id))
                {
                    SessionLocationService.Remove(v.SessionId, v.LocationId);
                }

                foreach (var v in QualificationDevelopedByCourseService.GetAll().Where(d => d.CourseId == Course.Id))
                {
                    QualificationDevelopedByCourseService.Remove(Course.Id, v.QualificationId);
                }

                foreach (var v in PrerequisitesForCourseService.GetAll().Where(d => d.CourseId == Course.Id))
                {
                    PrerequisitesForCourseService.Remove(Course.Id, v.QualificationId);
                }
                CourseService.RemoveCourse(Course);

                BackProc();
            }
        }
コード例 #3
0
        private void AddSessionAndLocation()
        {
            var randomCourse  = CourseService.GetAllCourses()[random.Next(100)];
            var randomAddress = AddressService.GetAllAdresses()[random.Next(100)];
            var newLocation   = LocationService.AddLocation(new Location()
            {
                Address = randomAddress,
            });
            var addedSession = new Session()
            {
                Course = randomCourse
            };

            SessionService.AddSession(addedSession);
            SessionLocationService.Add(new Session_Location()
            {
                Session  = addedSession,
                Location = newLocation
            });
        }