コード例 #1
0
        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)));
        }
コード例 #2
0
 public ActionResult Create()
 {
     ViewBag.UserGroups = new MultiSelectList(userGroupsHandler.All(), "id", "title");
     return(View());
 }
コード例 #3
0
 public ActionResult Index()
 {
     return(View(repository.All()));
 }