/// <summary>
        /// Handles the Clicked event of the OverPreRequest control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="TappedRoutedEventArgs"/> instance containing the event data.</param>
        private async void OverPreRequest_Clicked(object sender, TappedRoutedEventArgs e)
        {
            TextBlock tappedText = sender as TextBlock;
            Grid      tappedGrid = (tappedText.Parent as Border).Parent as Grid;
            var       viewBoxes  = from vb in tappedGrid.Children.OfType <Viewbox>()
                                   select vb;
            TextBlock courseText = viewBoxes.First().Child as TextBlock;

            System.Diagnostics.Debug.WriteLine("course Name = " + courseText.Text);

            DataServiceQuery <COURSE_AVAIL> cDsq = (DataServiceQuery <COURSE_AVAIL>)(from kc in ctx.COURSE_AVAIL
                                                                                     where kc.TITLE == courseText.Text
                                                                                     select kc);
            TaskFactory <IEnumerable <COURSE_AVAIL> > tf = new TaskFactory <IEnumerable <COURSE_AVAIL> >();
            COURSE_AVAIL tmpCourse        = (await tf.FromAsync(cDsq.BeginExecute(null, null), iar => cDsq.EndExecute(iar))).FirstOrDefault();
            Course       navigateToCourse = Constants.CourseAvail2Course(tmpCourse);

            Frame.Navigate(typeof(CourseOverview), navigateToCourse);
        }
Example #2
0
        /// <summary>
        /// Courses the rec2 course.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static Course CourseRec2Course(COURSE_AVAIL c)
        {
            Course course = new Course();

            course.Title     = c.TITLE;
            course.Intro     = c.INTRO;
            course.ID        = c.ID;
            course.Teacher   = c.TEACHER_NAME;
            course.Category  = "Recommendation";
            course.Price     = c.PRICE;
            course.Rate      = c.RATE;
            course.PG        = c.RESTRICT_AGE;
            course.LessonNum = c.LESSON_NUM;
            course.RatedUser = c.RATED_USERS;
            course.ImageUri  = DataCenterURI + c.ICON_URL.Replace('\\', '/');
            course.IsBuy     = false;
            course.IsTeach   = false;

            return(course);
        }
Example #3
0
 public void AddToCOURSE_AVAIL(COURSE_AVAIL cOURSE_AVAIL)
 {
     base.AddObject("COURSE_AVAIL", cOURSE_AVAIL);
 }
Example #4
0
 public static COURSE_AVAIL CreateCOURSE_AVAIL(int ID, decimal pRICE, string tITLE)
 {
     COURSE_AVAIL cOURSE_AVAIL = new COURSE_AVAIL();
     cOURSE_AVAIL.ID = ID;
     cOURSE_AVAIL.PRICE = pRICE;
     cOURSE_AVAIL.TITLE = tITLE;
     return cOURSE_AVAIL;
 }
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            course = e.Parameter as Course;


            //// Prerequisite initialization:



            /*
             * for (int i = 0; i < 30; ++i)
             * {
             *  AddToPreRequestCoursesPanel("Algorithm" + i);
             * }
             * AddToPreRequestCoursesPanel("We See");
             */


            List <Constants.DepCourse> results = Constants.DepCourse.GetDepCourses(course.Title);



            foreach (Constants.DepCourse dc in results)
            {
                System.Diagnostics.Debug.WriteLine("if learned");
                if (!Constants.DepCourse.IfLearned(dc.CourseName))
                {
                    System.Diagnostics.Debug.WriteLine("Learned");
                    AddToPreRequestCoursesPanel(dc.CourseName);
                }

                //System.Diagnostics.Debug.WriteLine(dc.CourseName);
            }



            try
            {
                DataServiceQuery <COURSE_AVAIL> cDsq = (DataServiceQuery <COURSE_AVAIL>)(from kc in ctx.COURSE_AVAIL
                                                                                         where course.ID == kc.ID
                                                                                         select kc);
                TaskFactory <IEnumerable <COURSE_AVAIL> > tf = new TaskFactory <IEnumerable <COURSE_AVAIL> >();
                COURSE_AVAIL tmpCourse = (await tf.FromAsync(cDsq.BeginExecute(null, null), iar => cDsq.EndExecute(iar))).FirstOrDefault();
                course = Constants.CourseAvail2Course(tmpCourse);
            }
            catch
            {
                ShowMessageDialog("Network connection error2!");
                Frame.GoBack();
            }

            UserProfileBt.DataContext = Constants.User;
            DataContext           = course;
            introGrid.DataContext = course;

            frame.Navigate(typeof(CourseDetail.Overview), course);

            isTeach = false;
            isBuy   = false;

            try
            {
                teachCourses = (DataServiceQuery <COURSE_AVAIL>)(from teachC in ctx.COURSE_AVAIL
                                                                 where teachC.TEACHER_NAME == Constants.User.NAME
                                                                 select teachC);
                TaskFactory <IEnumerable <COURSE_AVAIL> > teachTF = new TaskFactory <IEnumerable <COURSE_AVAIL> >();
                IEnumerable <COURSE_AVAIL> tcs = await teachTF.FromAsync(teachCourses.BeginExecute(null, null), iar => teachCourses.EndExecute(iar));

                buyCourses = (DataServiceQuery <ATTEND>)(from buyC in ctx.ATTEND
                                                         where buyC.CUSTOMER_ID == Constants.User.ID
                                                         select buyC);
                TaskFactory <IEnumerable <ATTEND> > buyCF = new TaskFactory <IEnumerable <ATTEND> >();
                IEnumerable <ATTEND> bcs = await buyCF.FromAsync(buyCourses.BeginExecute(null, null), iar => buyCourses.EndExecute(iar));


                foreach (var t in tcs)
                {
                    if (t.ID == course.ID)
                    {
                        isTeach = true;
                        break;
                    }
                }

                foreach (var b in bcs)
                {
                    if (b.COURSE_ID == course.ID)
                    {
                        isBuy = true;
                        break;
                    }
                }
            }
            catch
            {
                ShowMessageDialog("Network connection error3!");
                Frame.GoBack();
            }

            if (course.Price == null || course.Price.Value == 0)
            {
                PriceTextBlock.Text = "Free";
            }
            else
            {
                PriceTextBlock.Text = "$ " + Math.Round(course.Price.Value, 2);
            }
            System.Diagnostics.Debug.WriteLine(course.Rate);
            SetStarsStackPanel(course.Rate ?? 0);

            if (isTeach)
            {
                courseButton.Content = "Teach";
            }
            else if (isBuy)
            {
                courseButton.Content = "Attend";
            }
            else
            {
                courseButton.Content = "Buy";
            }
        }