public async Task <List <dynamic> > GetCourseListByFilterAndPaginationParameters(FilterParameters filterParameters, PaginationParameters paginationParameters)
        {
            var courses = await courseRepository.GetCourseListByFilterAndPaginationParameters(filterParameters, paginationParameters);

            var bestSellerCourses = await studentCourseRepository.Get10BestSellerCourseIDsInMonth();

            var newestCourses = await courseRepository.Get10NewestCourseIds();

            var mostViewedCourses = await viewRepository.Get10MostViewedCourseIds();    //InMonth

            List <dynamic> dynamicCourseList = new List <dynamic>();

            for (int c = 0; c < courses.Count; c++)
            {
                var rating = await feedbackRepository.GetRatingByCourseId(courses[c].Id);

                if (rating < filterParameters.MinRating || rating > filterParameters.MaxRating)
                {
                    continue;
                }

                dynamic course = new ExpandoObject();
                course.id                = courses[c].Id;
                course.price             = courses[c].Price;
                course.name              = courses[c].Name;
                course.imageUrl          = courses[c].ImageUrl;
                course.lastUpdated       = courses[c].LastUpdated;
                course.statusId          = courses[c].StatusId;
                course.status            = courses[c].Status;
                course.discount          = courses[c].Discount;
                course.shortDiscription  = courses[c].ShortDiscription;
                course.detailDiscription = courses[c].DetailDiscription;
                course.lecturerId        = courses[c].LecturerId;
                course.lecturer          = await userRepository.GetById(courses[c].LecturerId);

                course.rating         = rating;
                course.reviewerNumber = await feedbackRepository.GetReviewerNumberByCourseId(courses[c].Id);

                course.registeredNumber = await studentCourseRepository.GetRegisteredNumberByCourseId(courses[c].Id);

                bool flag = false;
                for (int b = 0; b < bestSellerCourses.Count; b++)
                {
                    if (bestSellerCourses[b].CourseId == courses[c].Id)
                    {
                        course.tag = "BestSeller";
                        flag       = true;
                        break;
                    }
                }

                if (flag == true)
                {
                    dynamicCourseList.Add(course);
                    continue;
                }

                for (int n = 0; n < newestCourses.Count; n++)
                {
                    if (newestCourses[n].CourseId == courses[c].Id)
                    {
                        course.tag = "Newest";
                        flag       = true;
                        break;
                    }
                }

                if (flag == true)
                {
                    dynamicCourseList.Add(course);
                    continue;
                }

                for (int m = 0; m < mostViewedCourses.Count; m++)
                {
                    if (mostViewedCourses[m].CourseId == courses[c].Id)
                    {
                        course.tag = "Trending";
                        flag       = true;
                        break;
                    }
                }

                dynamicCourseList.Add(course);
            }

            paginationParameters.TotalItems = dynamicCourseList.Count;
            paginationParameters.TotalPages = Convert.ToInt32(Math.Ceiling((double)dynamicCourseList.Count / paginationParameters.PageSize));
            paginationParameters.PageNumber = (paginationParameters.PageNumber > paginationParameters.TotalPages) ? paginationParameters.TotalPages : paginationParameters.PageNumber;


            return(dynamicCourseList.Skip((paginationParameters.PageNumber - 1) * paginationParameters.PageSize).Take(paginationParameters.PageSize).ToList());
        }
        public async Task <object> GetFormattedCategoryTypeById(int id)
        {
            var categoryType = await categoryTypeRepository.GetWithAllInfoById(id);

            var bestSellerCourses = await studentCourseRepository.Get10BestSellerCourseIDsInMonth();

            var newestCourses = await courseRepository.Get10NewestCourseIds();

            var mostViewedCourses = await viewRepository.Get10MostViewedCourseIds();    //InMonth


            IList <dynamic> dynamicCategoryList = new List <dynamic>();

            for (int i = 0; i < categoryType.Categories.Count; i++)
            {
                var courses = await courseRepository.GetByCategoryId(categoryType.Categories[i].Id);

                categoryType.Categories[i].Courses = null;  //?

                IList <dynamic> dynamicCourseList = new List <dynamic>();

                for (int c = 0; c < courses.Count; c++)
                {
                    dynamic course = new ExpandoObject();
                    course.id          = courses[c].Id;
                    course.price       = courses[c].Price;
                    course.name        = courses[c].Name;
                    course.imageUrl    = courses[c].ImageUrl;
                    course.lastUpdated = courses[c].LastUpdated;
                    course.statusId    = courses[c].StatusId;
                    course.status      = courses[c].Status;
                    course.discount    = courses[c].Discount;
                    //course.ShortDiscription = courses[c].ShortDiscription;
                    //course.DetailDiscription = courses[c].DetailDiscription;
                    course.lecturerId = courses[c].LecturerId;
                    course.lecturer   = await userRepository.GetById(courses[c].LecturerId);

                    course.rating = await feedbackRepository.GetRatingByCourseId(courses[c].Id);

                    course.reviewerNumber = await feedbackRepository.GetReviewerNumberByCourseId(courses[c].Id);

                    course.registeredNumber = await studentCourseRepository.GetRegisteredNumberByCourseId(courses[c].Id);

                    bool flag = false;
                    for (int b = 0; b < bestSellerCourses.Count; b++)
                    {
                        if (bestSellerCourses[b].CourseId == courses[c].Id)
                        {
                            course.tag = "BestSeller";
                            flag       = true;
                            break;
                        }
                    }

                    if (flag == true)
                    {
                        dynamicCourseList.Add(course);
                        continue;
                    }

                    for (int n = 0; n < newestCourses.Count; n++)
                    {
                        if (newestCourses[n].CourseId == courses[c].Id)
                        {
                            course.tag = "Newest";
                            flag       = true;
                            break;
                        }
                    }

                    if (flag == true)
                    {
                        dynamicCourseList.Add(course);
                        continue;
                    }

                    for (int m = 0; m < mostViewedCourses.Count; m++)
                    {
                        if (mostViewedCourses[m].CourseId == courses[c].Id)
                        {
                            course.tag = "Trending";
                            flag       = true;
                            break;
                        }
                    }

                    dynamicCourseList.Add(course);
                }


                dynamicCategoryList.Add(dynamicCourseList);
            }

            return(new
            {
                categoryType = categoryType,
                dynamicCategoryList = dynamicCategoryList
            });
        }