public IEnumerable <Data.Models.Course> SearchByStartDate(string startDate, int tenantId, string inBeforeOrAfter)
        {
            var categories      = new List <CourseCategory>();
            var repo            = new EducorDbRepo(null);
            var startDateString = startDate.Substring(0, 6);

            IEnumerable <Data.Models.Course> courses = repo.CourseQueries.GetAllAvailableForEnrolment(tenantId)
                                                       .Where(x => x.Semester.Substring(0, 6).Equals(startDateString)).ToList();

            switch (inBeforeOrAfter)
            {
            case "in":
                courses = repo.CourseQueries.GetAllAvailableForEnrolment(tenantId)
                          .Where(x => x.Semester.Substring(0, 6).Equals(startDateString)).ToList();
                break;

            case "before":
                courses = repo.CourseQueries.GetAllAvailableForEnrolment(tenantId)
                          .Where(x => string.Compare(x.Semester.Substring(0, 6), startDateString, false) < 0).ToList();
                break;

            default:
            case "after":
                courses = repo.CourseQueries.GetAllAvailableForEnrolment(tenantId)
                          .Where(x => string.Compare(x.Semester.Substring(0, 6), startDateString, false) >= 0);
                break;
            }

            return(courses);
        }
        public IEnumerable <Data.Models.Course> ShowAll(int tenantId)
        {
            var repo    = new EducorDbRepo(null);
            var courses = repo.CourseQueries.GetAllForTenant(tenantId);

            return(courses);
        }
        public IEnumerable <Data.Models.Course> SearchByName(string courseName, int tenantId)
        {
            var repo    = new EducorDbRepo(null);
            var courses = repo.CourseQueries.GetAllForTenant(tenantId).Where(x => x.IsVisible == true && x.Name.Contains(courseName)).ToList();

            return(courses);
        }
        public IEnumerable <Data.Models.Course> SearchByCategory(string category, int tenantId)
        {
            //var categories = new List<CourseCategory>();
            var repo    = new EducorDbRepo(null);
            var courses = repo.CourseQueries.GetAllAvailableForEnrolment(tenantId).Where(x => x.IsVisible == true && x.Name.Contains(category)).ToList();

            return(courses);
        }
示例#5
0
        private async Task ViewListOfAllCourses(IDialogContext context, IAwaitable <bool> result)
        {
            if (await result)
            {
                var tenantId = 1;

                var repo    = new EducorDbRepo(null);
                var courses = repo.CourseQueries.GetAllForTenant(tenantId).Where(x => x.IsVisible).ToList();

                var response = context.MakeMessage();
                response.Attachments      = new List <Attachment>();
                response.AttachmentLayout = AttachmentLayoutTypes.Carousel;

                var datesButtons = new CardAction()
                {
                    Type  = "openUrl",
                    Title = "View Details",
                    Value = "https://www.cityvarsityonline.com/course-schedule"
                };

                var pictureUrl = "https://www.cityvarsityonline.com/wp-content/uploads/2016/12/Creative-Writing.png";

                foreach (var course in courses)
                {
                    var thumbnail = new ThumbnailCard()
                    {
                        Title    = course.Name,
                        Subtitle = $"StartDate: {course.Semester}",
                        Buttons  = new List <CardAction>()
                    };
                    thumbnail.Buttons.Add(datesButtons);
                    thumbnail.Images.Add(new CardImage(pictureUrl));
                    response.Attachments.Add(thumbnail.ToAttachment());
                }

                await context.PostAsync("Please select course from our list below:");

                await context.PostAsync(response);

                context.Wait(MessageReceived);
            }
            else
            {
                await context.PostAsync("I'm sorry I must have misunderstood, please rephrase your query");

                context.Wait(MessageReceived);
            }
        }
示例#6
0
        private async Task ProcessSearchOption(IDialogContext context, IAwaitable <object> result)
        {
            var repo                = new EducorDbRepo(null);
            var chosenOption        = await result;
            var tenantId            = 1;
            var courseSearchService = new CourseSearchService();
            var reply               = context.MakeMessage();
            var pictureUrl          = "";


            switch (chosenOption.ToString())
            {
            case "Search by Course Category":

                reply.Attachments      = new List <Attachment>();
                reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;
                var courses          = new List <Data.Models.Course>();
                var courseCategories = CourseCategory.CreateList();

                var categoryButtons = new CardAction()
                {
                    Type  = "openUrl",
                    Title = "View Details",
                    Value = "https://www.cityvarsityonline.com/courses/"
                };

                foreach (var courseCategory in courseCategories)
                {
                    var thumbnail = new ThumbnailCard()
                    {
                        Title    = courseCategory.Title,
                        Subtitle = courseCategory.SubTitle,
                        Buttons  = new List <CardAction>()
                    };
                    thumbnail.Buttons.Add(categoryButtons);
                    thumbnail.Images.Add(new CardImage(courseCategory.PictureUrl));
                    reply.Attachments.Add(thumbnail.ToAttachment());
                }
                await context.PostAsync("Please Select the course category:");

                await context.PostAsync("Each link will take you to the website courses");

                await context.PostAsync(reply);

                break;

            case "Search by Course Start Date":

                var form = new FormDialog <StartDateForm>(
                    new StartDateForm(),
                    StartDateForm.BuildForm
                    );

                context.Call <StartDateForm>(form, DateFormComplete);

                break;

            case "Search by Course Name":

                await context.PostAsync("Please name the course you are looking for:");

                var courseName = await result;

                courses = repo.CourseQueries.GetAllForTenant(tenantId)
                          .Where(x => x.IsVisible && x.Name.Contains(courseName.ToString())).ToList();

                reply                  = context.MakeMessage();
                reply.Attachments      = new List <Attachment>();
                reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;

                var namesButtons = new CardAction()
                {
                    Type  = "openUrl",
                    Title = "View Details",
                    Value = "https://www.cityvarsityonline.com/course-schedule"
                };

                pictureUrl = "https://www.cityvarsityonline.com/wp-content/uploads/2016/12/Creative-Writing.png";

                foreach (var course in courses)
                {
                    var thumbnail = new ThumbnailCard()
                    {
                        Title    = course.Name,
                        Subtitle = $"Start Date: {course.Semester.Substring(0, 8)}\n" +
                                   $"End Date: {course.Semester.Substring(12, 20)}",
                        Buttons = new List <CardAction>()
                    };
                    thumbnail.Buttons.Add(namesButtons);
                    thumbnail.Images.Add(new CardImage(pictureUrl));
                    reply.Attachments.Add(thumbnail.ToAttachment());
                }

                await context.PostAsync("Here are courses with similar or related names:");

                await context.PostAsync(reply);

                break;

            default:
            // ReSharper disable once RedundantCaseLabel
            case "Show All Courses on Offer":

                //PromptDialog.Confirm(context, ViewListOfAllCourses, "Please confirm that want to view all courses?",
                //    "Please click an option below or type 'yes' or 'no'", 2, PromptStyle.Auto, new string[] { "YES", "NO" });


                tenantId = 1;

                repo    = new EducorDbRepo(null);
                courses = repo.CourseQueries.GetAllForTenant(tenantId).Where(x => x.IsVisible).ToList();

                var response = context.MakeMessage();
                response.Attachments      = new List <Attachment>();
                response.AttachmentLayout = AttachmentLayoutTypes.Carousel;

                var datesButtons = new CardAction()
                {
                    Type  = "openUrl",
                    Title = "View Details",
                    Value = "https://www.cityvarsityonline.com/course-schedule"
                };

                pictureUrl = "https://www.cityvarsityonline.com/wp-content/uploads/2016/12/Creative-Writing.png";

                foreach (var course in courses)
                {
                    var thumbnail = new ThumbnailCard()
                    {
                        Title    = course.Name,
                        Subtitle = $"Price: R{ course.OriginalCost}\n" +
                                   $"College: City Varsity Online\n" +
                                   $"Start Date: {course.Semester}\n \n",
                        Buttons = new List <CardAction>()
                    };
                    thumbnail.Buttons.Add(datesButtons);
                    thumbnail.Images.Add(new CardImage(pictureUrl));
                    response.Attachments.Add(thumbnail.ToAttachment());
                }

                await context.PostAsync("Please select course from our list below:");

                await context.PostAsync(response);

                context.Wait(MessageReceived);
                break;
            }
        }