Beispiel #1
0
 public void AddOffering(Offering offering)
 {
     offerings.Add(offering);
     _Lectures.Add(offering.Lecture);
     foreach (Section tutorial in offering.Tutorials)
     {
         _Tutorials.Add(tutorial);
     }
     foreach (Section lab in offering.Labs)
     {
         _Labs.Add(lab);
     }
 }
Beispiel #2
0
        public void Execute(object parameter)
        {
            Offering selected = course.SelectedOffering();

            if (selected != null)
            {
                CourseSelectorCourses.RemoveCourse(course);
                CartAndScheduleEntry entry = CartSelections.AddToCart(course);
                Messages.AddUndoMessage("Added " + course.Department + " " + course.Number + " in " + entry.Semester + " to Cart", () => CartSelections.RemoveFromCart(entry));
            }
            else
            {
                MessageBox.Show("Please ensure all sections (lecture/tutorial/lab) are selected for the course you wish to add");
            }
        }
Beispiel #3
0
        public Offering SelectedOffering()
        {
            Offering chosen = null;

            foreach (Offering offering in offerings)
            {
                if (offering.Lecture.IsChecked == true)
                {
                    if (offering.Tutorials.Count > 0)
                    {
                        bool isChecked = false;
                        foreach (Section tutorial in offering.Tutorials)
                        {
                            if (tutorial.IsChecked == true)
                            {
                                isChecked = true;
                                break;
                            }
                        }
                        if (!isChecked)
                        {
                            break;
                        }
                    }
                    if (offering.Labs.Count > 0)
                    {
                        bool isChecked = false;
                        foreach (Section lab in offering.Labs)
                        {
                            if (lab.IsChecked == true)
                            {
                                isChecked = true;
                                break;
                            }
                        }
                        if (!isChecked)
                        {
                            break;
                        }
                    }
                    chosen = offering;
                    break;
                }
            }
            return(chosen);
        }
        public static CartAndScheduleEntry AddToCart(Course course)
        {
            Console.WriteLine("Moving this course to cart");

            Offering selected       = course.SelectedOffering();
            Section  chosenLecture  = selected.Lecture;
            Section  chosenTutorial = null;
            Section  chosenLab      = null;

            if (selected.Tutorials.Count > 0)
            {
                foreach (Section tutorial in selected.Tutorials)
                {
                    if (tutorial.IsChecked == true)
                    {
                        chosenTutorial = tutorial;
                        break;
                    }
                }
            }
            if (selected.Labs.Count > 0)
            {
                foreach (Section lab in selected.Labs)
                {
                    if (lab.IsChecked == true)
                    {
                        chosenLab = lab;
                        break;
                    }
                }
            }
            CartAndScheduleEntry entry = new CartAndScheduleEntry(course.Department, course.Number, course.Title, course.Semester, course.SemesterObject, chosenLecture, chosenLab, chosenTutorial);

            instance.cart.Insert(0, entry);
            if (instance.visibleSemesters.Contains(entry.SemesterObject))
            {
                instance.visible.Insert(0, entry);
                NotifyChange(NotifyCollectionChangedAction.Add, entry);
            }
            return(entry);
        }