private async Task <LawofficeContext> ConfiguraGerenciador(LawofficeContext context, IGerenciadorDeRequisicoes gerenciador) { if (context == null) { context = (LawofficeContext)JsonConvert.DeserializeObject(Request.Headers[Parametros.TOKEN_CONTEXTO]); } return(context); }
public async Task <IActionResult> ListaFavorecimentos(int idContrato, LawofficeContext context = null) { context = await ConfiguraGerenciador(context, _gerenciadorDeRequisicoesDeFavorecimento); IFavorecimento[] favorecimentos = null; try { favorecimentos = await _gerenciadorDeRequisicoesDeFavorecimento.ListaFavorecimentosDeAsync(idContrato, Definicoes.ID_VINCULO_FAVORECIMENTO_CONTRATO); } catch (Exception ex) { return(BadRequest(ex)); } return(Ok(favorecimentos)); }
public async Task <IActionResult> ListaFavorecidosPorCategoria(int idContrato, LawofficeContext context = null) { context = await ConfiguraGerenciador(context, _gerenciadorDeRequisicoesDeFavorecimento); IFavorecimento[] favorecimentos = null; try { const string TIPO_FAVORECIMENTO = "FAVORECIMENTO_POR_CATEGORIA"; favorecimentos = await _gerenciadorDeRequisicoesDeFavorecimento.ListarFavorecimentoPorCategoriaAsync(idContrato, Definicoes.ID_VINCULO_FAVORECIMENTO_CONTRATO, TIPO_FAVORECIMENTO); } catch (Exception Ex) { return(BadRequest(Ex)); } return(Ok(favorecimentos)); }