public JsonResult ConfiguracaoUsuario(ConfiguracaoUsuarioModel model)
 {
     var response = ServiceRequest.Put<RetornoBase<string>>(model, "api/Usuario/EditarPermissaoUsuario");
     if (response.StatusCode != HttpStatusCode.OK)
     {
         return ReturnResponse(response);
     }
     var ret = ServiceRequest.Get<List<PermissaoModel>>("api/Usuario/ObterPermissoesUsuarioLogado");
     if (ret.StatusCode != HttpStatusCode.OK || ret.Data == null)
     {
         return ReturnResponse(response);
     }
     var roles =
         JsonConvert.SerializeObject(
             ret.Data.ObjetoRetorno.Select(x => x.AcaoNome).ToArray());
     Response.UpdateRolesCookie(roles);
     return ReturnResponse(response);
 }
コード例 #2
0
        public Task<HttpResponseMessage> EditarPermissaoUsuario(ConfiguracaoUsuarioModel model)
        {
            HttpResponseMessage response;
            try
            {
                if (!model.UsuarioId.HasValue)
                {
                    throw new Exception(string.Format(Erros.NullParameter, "UsuarioId"));
                }
                _usuarioService.EditarPermissaoUsuario(model.UsuarioId.Value,
                    Mapper.Map<List<Permissao>>(model.Permissoes));
                response = ReturnSuccess();
            }
            catch (Exception ex)
            {
                response = ReturnError(ex);
            }

            var tsc = new TaskCompletionSource<HttpResponseMessage>();
            tsc.SetResult(response);
            return tsc.Task;
        }
 public JsonResult ConfiguracaoUsuario(ConfiguracaoUsuarioModel model)
 {
     var response = ServiceRequest.Put<RetornoBase<string>>(model, "api/Usuario/EditarPermissaoUsuario");
     AtualizarPermissoesDoUsuarioLogado();
     return ReturnResponse(response);
 }