public async Task <IActionResult> Listar(string paginaId, string perfilId, jQueryDataTableRequestModel request) { try { var lista = (await _repositorio.ObterPermissaosAsync(paginaId.Equals("0") ? null : paginaId, perfilId.Equals("0") ? null : perfilId)).AsQueryable(); if (request.sSearch != null && request.sSearch.Length > 0) { lista = lista.Where(x => x.DesPagina.ToUpper().Contains(request.sSearch.ToUpper()) || x.DesPapel.ToUpper().Contains(request.sSearch.ToUpper())); } var model = (from r in lista select new { PermissaoId = $"{r.PapelId }{r.PaginaId}", r.PaginaId, r.PapelId, desPapel = $" {r.DesPapel }<input type = \"hidden\" value = \"{r.PapelId }\" />", desPagina = $" {r.DesPagina }<input type = \"hidden\" value = \"{r.PaginaId }\" />", Criar = $"<label class=\"custom-control custom-checkbox\"><input {(r.Criar ? "checked" : "")} type = \"checkbox\" class=\"custom-control-input\" /><span class=\"custom-control-indicator\"></span></label>", Editar = $"<label class=\"custom-control custom-checkbox\"><input {(r.Editar ? "checked" : "")} type = \"checkbox\" class=\"custom-control-input\" /><span class=\"custom-control-indicator\"></span></label>", Deletar = $"<label class=\"custom-control custom-checkbox\"><input {(r.Excluir ? "checked" : "")} type = \"checkbox\" class=\"custom-control-input\" /><span class=\"custom-control-indicator\"></span></label>", Ler = $"<label class=\"custom-control custom-checkbox\"><input {(r.Ler ? "checked" : "")} type = \"checkbox\" class=\"custom-control-input\" /><span class=\"custom-control-indicator\"></span></label>", Acao = ObterMenuAcaoDataTable(r) }).DataTableResponse(request); return(Ok(model)); } catch (System.Exception ex) { throw; } }
public List <PermissaoResultadoQuery> ObterListaPermissao(string perfil) { var cache = new CacheManager(); var chavePerfil = $"{chave}.{perfil}"; var lista = cache.ObterDoCache <List <PermissaoResultadoQuery> >(chavePerfil); if (lista == null) { lista = _repositorio.ObterPermissaosAsync(perfil); cache.AdicionarAoCache(lista, chavePerfil, 14000); } return(lista); }