Пример #1
0
        public ActionResult Index(string Keywords, string sortOrder, int?page)
        {
            ViewBag.CurrentSort   = sortOrder;
            ViewBag.CurrentFilter = Keywords;

            ViewBag.NameSortParm        = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            ViewBag.DescriptionSortParm = sortOrder == "Description" ? "Description_desc" : "Description";

            var Forminfs = _FormInfoService.GetAll();

            switch (sortOrder)
            {
            case "name_desc":
                Forminfs = Forminfs.OrderByDescending(s => s.Name);
                break;

            case "Description":
                Forminfs = Forminfs.OrderBy(s => s.Description);
                break;

            default:
                Forminfs = Forminfs.OrderBy(s => s.Name);
                break;
            }
            if (!string.IsNullOrWhiteSpace(Keywords))
            {
                Forminfs = Forminfs.Where(frm => frm.Name.Contains(Keywords));
            }
            int pageSize   = 4;
            int pageNumber = (page ?? 1);

            return(View(Forminfs.ToPagedList(pageNumber, pageSize)));
        }
Пример #2
0
        public ActionResult Create()
        {
            var model = new FormAccessViewModel();

            model.frms = new SelectList(_FormInfoService.GetAll(), "Id", "Name");
            model.Rols = new SelectList(_RoleServices.GetAll(), "Id", "Name");
            return(View(model));
        }