public ActionResult Gerar(byte mes, short ano, bool incluiLancamentosPrevisto) { var response = _lancamentoAppService.GetAll(UsuarioLogado.Id, mes, ano); if (!response.IsSuccessStatusCode) { return(Error(response)); } var lancamentos = Deserialize <IEnumerable <LancamentoDto> >(response).Select(x => new LancamentoViewModel(x)).ToList(); if (!incluiLancamentosPrevisto) { lancamentos = lancamentos.Where(x => x.IsPagoRecebido).ToList(); } if (!lancamentos.Any()) { return(Error("Você não possui movimentações para este mês")); } var excel = LancamentoReport.GetExcel(lancamentos); return(File(new MemoryStream(excel.GetAsByteArray()), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", $"Lancamentos {DateTime.Now:yyyyMMddHHmmss}.xlsx")); }
public ActionResult Home() { if (UsuarioLogado == null) { return(View("../Login/Login")); } var response = _lancamentoAppService.GetAll(UsuarioLogado.Id); if (!response.IsSuccessStatusCode) { return(Error(response)); } var lancamentos = JsonConvert.DeserializeObject <IEnumerable <LancamentoDto> >(response.Content.ReadAsStringAsync().Result) .Select(x => new LancamentoViewModel(x)).ToList(); var responsePossuiOpcaoTransferencia = _transferenciaAppService.GetVerificaClientePossuiTransferenciaHabilitada(UsuarioLogado.Id); ViewBag.PossuiOpcaoTransferencia = responsePossuiOpcaoTransferencia.IsSuccessStatusCode; ViewBag.Email = UsuarioLogado.Email; ViewBag.Id = UsuarioLogado.Id; var responseOpcMenu = _acessoOpcaoMenuAppService.Post(UsuarioLogado.Id, 1); // 1: codigo opção menu "HOME" if (!responseOpcMenu.IsSuccessStatusCode) { return(Error(responseOpcMenu)); } ViewBag.PrimeiroAcesso = Deserialize <int>(responseOpcMenu) < 1 ? "S" : "N"; return(View("Home", new HomeViewModel { Lancamentos = lancamentos })); }
public ActionResult Lancamento(int?idConta = null, int?idCategoria = null, byte?mes = null, short?ano = null) { #region combo conta var responseConta = _contaFinanceiraAppService.GetAll(UsuarioLogado.Id); if (!responseConta.IsSuccessStatusCode) { return(Error(responseConta)); } var contas = JsonConvert.DeserializeObject <IEnumerable <ContaFinanceiraDto> >(responseConta.Content.ReadAsStringAsync().Result).ToList(); if (!contas.Any()) { return(Error("Antes de visualizar lançamentos é necessario cadastrar uma conta")); } #endregion #region combo categoria var responseCategoria = _lancamentoCategoriaAppService.GetAll(UsuarioLogado.Id); if (!responseCategoria.IsSuccessStatusCode) { return(Error(responseCategoria)); } var categorias = JsonConvert.DeserializeObject <IEnumerable <LancamentoCategoriaDto> >(responseCategoria.Content.ReadAsStringAsync().Result).ToList(); if (!categorias.Any()) { return(Error("Antes de visualizar lançamentos é necessario cadastrar categorias")); } #endregion mes = (byte?)(mes ?? DateTime.Today.Month); ano = (short?)(ano ?? DateTime.Today.Year); var response = _lancamentoAppService.GetAll(UsuarioLogado.Id, (byte)mes, (short)ano, idConta, idCategoria); if (!response.IsSuccessStatusCode) { return(Error(response)); } var lancamentos = JsonConvert.DeserializeObject <IEnumerable <LancamentoDto> >(response.Content.ReadAsStringAsync().Result) .Select(x => new LancamentoViewModel(x) { UsuarioPodeManipularLancamento = UsuarioLogado.Id == x.IdUsuarioCadastro }).ToList(); var responsePossuiOpcaoTransferencia = _transferenciaAppService.GetVerificaClientePossuiTransferenciaHabilitada(UsuarioLogado.Id); ViewBag.PossuiOpcaoTransferencia = responsePossuiOpcaoTransferencia.IsSuccessStatusCode; var responseOpcMenu = _acessoOpcaoMenuAppService.Post(UsuarioLogado.Id, 3); // 3: codigo opção menu "Lancamentos" if (!responseOpcMenu.IsSuccessStatusCode) { return(Error(responseOpcMenu)); } ViewBag.PrimeiroAcesso = Deserialize <int>(responseOpcMenu) < 1 ? "S" : "N"; return(View("Lancamento", new LancamentoMasterViewModel(lancamentos, (byte)mes, (short)ano, idConta, idCategoria) { Contas = contas, Categorias = categorias })); }
// GET: api/Lancamento public IEnumerable <LancamentoViewModel> Get() { return(_lancamentoAppService.GetAll()); }