public ActionResult GetListGenre(IDataTablesRequest dataTableParam, ResourceGenreSearchViewModel searchViewModel)
 {
     return Json(ResourceBusiness.GetListGenre(dataTableParam, searchViewModel));
 }
        public DataTablesResponse GetListGenre(IDataTablesRequest dataTableParam, ResourceGenreSearchViewModel searchViewModel)
        {
            try
            {
                var query = ResourceRepository.GetAll(x => x.IsDeleted == false && x.Type == (int) ResourceType.Genre, null, x => x.Genres);
                if (searchViewModel.GenreId > 0)
                {
                    query = query.Where(x => x.Genres.Any(g => g.IsDeleted == false && g.Id == searchViewModel.GenreId));
                }

                var dataTableHelper = new DataTableHelper<ResourceGenreViewModel, Resource>(query, x => new ResourceGenreViewModel
                {
                    Id = x.Id,
                    Url = x.Url,
                    Tag = x.Tag,
                    Genre = x.Genres.AsQueryable().Any(y => y.IsDeleted == false) ? x.Genres.AsQueryable().FirstOrDefault().Title : ""
                });

                var entities = dataTableHelper.GetDataVMForResponse(dataTableParam);
                var result = dataTableHelper.GetDataToList(dataTableParam, entities);

                return new DataTablesResponse(dataTableParam.Draw, result, entities.Count(), entities.Count());
            }
            catch (Exception ex)
            {
                Provider.Instance.LogError(ex);
                return new DataTablesResponse(dataTableParam.Draw, new List<ResourceGenreViewModel>(), 0, 0);
            }
        }