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)));
        }
        // GET: Albums
        public ActionResult Index(int?page, int?language, string search)
        {
            var albums = albumHandler.All();

            // Filter:
            if (language != null && language != 0)
            {
                albums = albums.Where(m => m.language_id == language);
            }
            // Search:
            albums = albumHandler.Search(albums, search);

            List <Languages> languageList = languageHandler.All().ToList();

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

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

            return(View(albums.ToPagedList(pageNumber, pageSize)));
        }
 public ActionResult Create()
 {
     ViewBag.language_id = new SelectList(languagesHandler.All(), "id", "title");
     return(View());
 }