예제 #1
0
        public bool CriarDocumento(UsuarioExternoModel usuario)
        {
            SalvarLog("Início criar Documento.");
            var api    = _configuration["API"];
            var client = _clientFactory.CreateClient();
            var data   = JsonConvert.SerializeObject(usuario.ToDocumentoDTO());

            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
            SalvarLog("Executando api documentos.");
            var response = client.PostAsync($"{api}/v2/documentos?pastaId={159975}&tipoDocumentoId={18}", new StringContent(data, Encoding.UTF8, "application/json"));

            SalvarLog("Api executada. Resultado: " + response.Result.StatusCode);
            if (response.Result.StatusCode == System.Net.HttpStatusCode.Created)
            {
                DocumentoVersao result;
                var             jsonString = response.Result.Content.ReadAsStringAsync();

                result = JsonConvert.DeserializeObject <DocumentoVersao>(jsonString.Result);
                var documentoId = 0;
                var processoId  = 36;

                documentoId = result.DocumentoId;

                IniciarProcesso(processoId, documentoId);
                return(true);
            }
            else
            {
                SalvarLog("Api retornou" + response.Result.StatusCode);
                throw new Exception("Erro ao realizar cadastro. Status: " + response.Result.StatusCode);
            }
        }
예제 #2
0
 public async Task <IActionResult> RetornaDocumentoDTO(UsuarioExternoModel documento)
 {
     return(Json(documento.ToDocumentoDTO()));
 }