public ActionResult Index(int?page, int?site, string search, string orderFeild, string prevOrder, int?category)
        {
            IQueryable <Contents> content = _contentHandler.All();

            //filter
            if (category != null && category != 0)
            {
                content = content.Where(c => c.category_id == category);
            }

            List <Categories> categories = _categoriesHandler.All().ToList();

            categories.Insert(0, new Categories {
                id = 0, title = "All"
            });
            ViewBag.category = new SelectList(categories, "id", "title");

            if (site != null && site != 0)
            {
                content = content.Where(c => c.site_id == site);
            }

            List <Sites> sites = _sitesHandler.All().ToList();

            sites.Insert(0, new Sites {
                id = 0, title = "All"
            });
            ViewBag.site = new SelectList(sites, "id", "title");

            //search
            content = _contentHandler.Search(content, search);

            //sorting
            content = _contentHandler.Sorting(content, ref orderFeild, ref prevOrder);

            //сохранение состояния выбора пользователя
            ViewBag.SearchState   = search;
            ViewBag.PrevState     = prevOrder;
            ViewBag.CategoryState = category;
            ViewBag.SiteState     = site;

            var contentMapper =
                Mapper.Map <IEnumerable <Contents>, List <ContentViewModel> >(content);

            int pageSize   = PagingSettings.PageSizeInContent;
            int pageNumber = (page ?? 1);

            return(View(contentMapper.ToPagedList(pageNumber, pageSize)));
        }
        public ActionResult Index(int?page, string search,
                                  string orderFeild, string prevOrder, //for sorting
                                  int?language, string userGroup)      //for filter
        {
            var categories = repository.All();

            //TODO показывать UserGroup - in create сделать выбор UserGroups

            //TODO доделать view что бы отображалось UserGroups in Edit Create Deteils

            //TODO использовать написсанные интерфейсы
            //filter
            if (language != null && language != 0)
            {
                categories = categories.Where(c => c.language_id == language);
            }

            List <Languages> languages = _languagesHandler.All().ToList();

            languages.Insert(0, new Languages {
                id = 0, title = "All"
            });
            ViewBag.Language = new SelectList(languages, "id", "title");

            if (userGroup != null && userGroup != null)
            {
                categories = categories.Where(c => c.IdentityRoles.Any(ug => ug.Id == userGroup));
            }

            List <IdentityRoles> userGroups = _usergroupsHandler.All().ToList();

            userGroups.Insert(0, new IdentityRoles {
                Id = "0", Name = "All"
            });
            ViewBag.UserGroup = new SelectList(userGroups, "id", "title");


            //serch
            categories = repository.Search(categories, search);


            //sorting
            categories = repository.Sorting(categories, ref orderFeild, ref prevOrder);

            //сохранение состояния выбора пользователя
            ViewBag.SearchState = search;
            ViewBag.PrevState   = prevOrder;
            ViewBag.LangState   = language;
            ViewBag.UsGrState   = userGroup;


            int pageSize   = PagingSettings.PageSizeInCategories;
            int pageNumber = (page ?? 1);

            return(View(categories.ToPagedList(pageNumber, pageSize)));
        }