Exemplo n.º 1
0
        public async Task <IActionResult> Index()
        {
            var result = await _authorizationService.AuthorizeAsync(User, FunctionConstant.Role, Operations.Read);

            if (!result.Succeeded)
            {
                return(Redirect(RouteConstant.PageForbidden));
            }
            string strStatus = HttpContext.Request.Query["status"];

            string pageCurrent = HttpContext.Request.Query["page"];

            string pageSize = HttpContext.Request.Query["pageSize"];

            string search = HttpContext.Request.Query["search"];

            string pathUrl = HttpContext.Request.Path;

            string queryString = HttpContext.Request.QueryString.ToString();

            if (string.IsNullOrEmpty(strStatus))
            {
                strStatus = StatusConstant.All;
            }

            var selectListStatus = new SelectList(StatusList.GetListStatusObject(), "Value", "Text", strStatus);

            Status status = StatusConstant.GetStatus(strStatus);

            if (string.IsNullOrEmpty(pageCurrent))
            {
                pageCurrent = "0";
            }
            if (string.IsNullOrEmpty(pageSize))
            {
                pageSize = "10";
            }

            int intPageCurrent = PageHelper.ReturnDefaultValuePageCurrent(int.Parse(pageCurrent));

            int intPageSize = PageHelper.ReturnDefaultValuePageSize(int.Parse(pageSize));

            var roles = _appRoleServiceInterface.GetAll(status, search, intPageCurrent, intPageSize);

            string curentUrlPath = PageHelper.ReturnPageCurrentPagination(pathUrl, queryString);

            var selectListPagination = new SelectList(StatusList.GetListPaginate(), "Value", "Text", intPageSize);

            ViewBag.StatusSelectListItem = selectListStatus;
            ViewBag.PathUrl = curentUrlPath;
            ViewBag.PaginationSelectListItem = selectListPagination;
            ViewBag.Search = search;
            return(View(roles));
        }