public static CartAndScheduleEntry AddToCart(CartAndScheduleEntry entry)
 {
     instance.cart.Insert(0, entry);
     if (instance.visibleSemesters.Contains(entry.SemesterObject))
     {
         instance.visible.Insert(0, entry);
         NotifyChange(NotifyCollectionChangedAction.Add, entry);
     }
     return(entry);
 }
 public static void AddToSchedule(CartAndScheduleEntry entry)
 {
     Console.WriteLine("Moving this course to schedule");
     instance.schedule.Insert(0, entry);
     if (instance.visibleSemesters.Contains(entry.SemesterObject))
     {
         instance.visible.Insert(0, entry);
         NotifyChange(NotifyCollectionChangedAction.Add, entry);
     }
 }
 private static void NotifyChange(NotifyCollectionChangedAction action, CartAndScheduleEntry entry)
 {
     if (instance.CollectionChanged != null)
     {
         instance.CollectionChanged(instance, new NotifyCollectionChangedEventArgs(action));
         Console.WriteLine("Notified change in cart");
     }
     else
     {
         Console.WriteLine("Did not notify change in cart");
     }
 }
Exemple #4
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");
            }
        }
 public static void RemoveFromSchedule(CartAndScheduleEntry entry)
 {
     if (instance.visible.Contains(entry))
     {
         instance.visible.Remove(entry);
         if (instance.CollectionChanged != null)
         {
             instance.CollectionChanged(instance, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, entry));
         }
     }
     if (instance.schedule.Contains(entry))
     {
         instance.schedule.Remove(entry);
     }
 }
        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);
        }
 public void reverseEnroll(CartAndScheduleEntry entry)
 {
     entry.UpdateRemoveFromCart();
     CartSelections.AddToCart(entry);
     ScheduleSelections.RemoveFromSchedule(entry);
 }
 public EnrollCourseCommand(CartAndScheduleEntry entry)
 {
     this.entry = entry;
 }
 public RemoveFromCartCommand(CartAndScheduleEntry entry)
 {
     this.entry = entry;
 }