public async Task <IKnowledgeHubResponse> GetCoursesbyCategories(int categoryId, int profileid, int skip = 0, int take = 5)
        {
            try
            {
                var courses = await _appDbContext.KnowledgeHubCourses.Include(a => a.Category).Include(a => a.ProviderType).Include(a => a.CourseType).Where(e => e.CategoryId == categoryId && !e.IsHide).Skip(skip).Take(take)
                              .ToListAsync();

                List <KnowledgeHubCourseView> _courses = new List <KnowledgeHubCourseView>();
                //var cours = _appDbContext.KnowledgeHubCourses.Include(a => a.ProviderType).Include(a => a.CourseType).Where(a => a.CategoryId == item.Id).ToList();
                foreach (var course in courses)
                {
                    KnowledgeHubCourseView _course = new KnowledgeHubCourseView();
                    _course.ID               = course.Id;
                    _course.IDEncyrpted      = this._encryptor.Encrypt(course.Id.ToString());
                    _course.NameEN           = course.NameEn;           //new EnglishArabicView(e.NameEn, e.NameAr),
                    _course.NameAR           = course.NameAr;
                    _course.AboutEN          = course.AboutEn != null ? course.AboutEn : "";
                    _course.AboutAR          = course.AboutAr != null ? course.AboutAr : "";
                    _course.CategoryID       = course.CategoryId;
                    _course.CategoryNameEn   = course.Category != null ? course.Category.TitleEn : "";                  // e.Category != null ? language == LanguageType.EN? e.Category.TitleEn: e.Category.TitleAr : "",
                    _course.CategoryNameAr   = course.Category != null ? course.Category.TitleAr : "";
                    _course.ProviderTypeEn   = course.ProviderType != null ? course.ProviderType.NameEn : "";           // language == LanguageType.EN ? e.ProviderType.NameEn: e.ProviderType.NameAr,
                    _course.ProviderTypeAr   = course.ProviderType != null ? course.ProviderType.NameAr : "";
                    _course.IsHide           = course.IsHide;
                    _course.IframeUrlEN      = course.IframeUrlEn != null ? course.IframeUrlEn : "";               // new EnglishArabicView(e.IframeUrlEn, e.IframeUrlAr),
                    _course.IframeUrlAR      = course.IframeUrlAr != null ? course.IframeUrlAr : "";
                    _course.To               = course.To ?? null;
                    _course.From             = course.From ?? null;
                    _course.Language         = course.Language;
                    _course.ShowProviderIcon = course.ShowProviderIcon;
                    _course.DescriptionEN    = course.DescriptionEn != null ? course.DescriptionEn : "";                 // new EnglishArabicView(e.DescriptionEn, e.DescriptionAr),
                    _course.DescriptionAR    = course.DescriptionAr != null ? course.DescriptionAr : "";
                    _course.CourseTypeEn     = course.CourseType != null ? course.CourseType.NameEn : "";                // language == LanguageType.EN ? e.CourseType.NameEn: e.CourseType.NameAr,
                    _course.CourseTypeAr     = course.CourseType != null ? course.CourseType.NameAr : "";
                    _course.ImageURL         = course.ImageUrl;
                    _course.CourseTypeID     = course.CourseTypeId;
                    _course.ProviderTypeID   = course.ProviderTypeId;
                    var profilecourse = _appDbContext.ProfileKnowledgeHubCourses.FirstOrDefault(a => a.CourseId == course.Id && a.ProfileId == profileid);
                    if (profilecourse != null)
                    {
                        _course.IsFavourite = true;
                    }
                    else
                    {
                        _course.IsFavourite = false;
                    }
                    _courses.Add(_course);
                }
                return(new KnowledgeHubResponse(_courses));
            }
            catch (Exception e)
            {
                return(new KnowledgeHubResponse(e));
            }
        }
        public async Task <IKnowledgeHubResponse> GetKnowledgeHubCourses(string searchText, int profileid, int?providerTypeId, int?categoryId, bool ishide, LanguageType language = LanguageType.AR, int skip = 0, int take = 5)
        {
            try
            {
                KnowledgeHubCourseView hubCourseViewModel = new KnowledgeHubCourseView();
                var source = _appDbContext.KnowledgeHubCourses.AsQueryable <KnowledgeHubCourse>();
                if (!string.IsNullOrEmpty(searchText))
                {
                    source = source.Where(e => e.NameEn.Contains(searchText) || e.NameAr.Contains(searchText));
                }
                if (providerTypeId.HasValue)
                {
                    source = source.Where(e => e.ProviderTypeId == providerTypeId.Value);
                }
                if (categoryId.HasValue)
                {
                    source = source.Where(e => e.CategoryId == categoryId);
                }
                if (ishide)
                {
                    source = source.Where(e => !e.IsHide);
                }

                var list = await source.Where(a => a.CategoryId.HasValue).OrderBy(e => e.CategoryId.HasValue).Select(e => new KnowledgeHubCourseView()
                {
                    ID               = e.Id,
                    IDEncyrpted      = this._encryptor.Encrypt(e.Id.ToString()),
                    NameEN           = e.NameEn,           //new EnglishArabicView(e.NameEn, e.NameAr),
                    NameAR           = e.NameAr,
                    AboutEN          = e.AboutEn != null ? e.AboutEn : "",
                    AboutAR          = e.AboutAr != null ? e.AboutAr : "",
                    CategoryID       = e.CategoryId,
                    CategoryNameEn   = e.Category != null ? e.Category.TitleEn : "",                  // e.Category != null ? language == LanguageType.EN? e.Category.TitleEn: e.Category.TitleAr : "",
                    CategoryNameAr   = e.Category != null ? e.Category.TitleAr : "",
                    ProviderTypeEn   = e.ProviderType != null ? e.ProviderType.NameEn : "",           // language == LanguageType.EN ? e.ProviderType.NameEn: e.ProviderType.NameAr,
                    ProviderTypeAr   = e.ProviderType != null ? e.ProviderType.NameAr : "",
                    IsHide           = e.IsHide,
                    IframeUrlEN      = e.IframeUrlEn != null ? e.IframeUrlEn : "",               // new EnglishArabicView(e.IframeUrlEn, e.IframeUrlAr),
                    IframeUrlAR      = e.IframeUrlAr != null ? e.IframeUrlAr : "",
                    To               = e.To,
                    From             = e.From,
                    Language         = e.Language,
                    ShowProviderIcon = e.ShowProviderIcon,
                    DescriptionEN    = e.DescriptionEn != null ? e.DescriptionEn : "",                 // new EnglishArabicView(e.DescriptionEn, e.DescriptionAr),
                    DescriptionAR    = e.DescriptionAr != null ? e.DescriptionAr : "",
                    CourseTypeEn     = e.DescriptionAr != null ? e.CourseType.NameEn : "",             // language == LanguageType.EN ? e.CourseType.NameEn: e.CourseType.NameAr,
                    CourseTypeAr     = e.CourseType != null ? e.CourseType.NameAr : "",
                    ImageURL         = e.ImageUrl,
                    CourseTypeID     = e.CourseTypeId,
                    ProviderTypeID   = e.ProviderTypeId,
                    IsFavourite      = _appDbContext.ProfileKnowledgeHubCourses.FirstOrDefault(a => a.CourseId == e.Id && a.ProfileId == profileid) != null ? true : false
                }).ToListAsync();

                return(new KnowledgeHubResponse(list.Skip(skip).Take(take).ToList())
                {
                    CourseCount = list.Count()
                });
            }
            catch (Exception e)
            {
                return(new KnowledgeHubResponse(e));
            }
        }