public async Task <IActionResult> Gastos(Transacao transacao) { transacao.Id = 0; Despesa despesa = null; if (!ModelState.IsValid) { var obj = await _despesaService.ObterPorIdAsync(transacao.FundoId.Value); transacao = _transacaoService.ObterInstanciaGastoDespesa(transacao.Despesa); List <Conta> contas = await _contaService.ObterTodosAsync(); TransacaoFormViewModel viewModel = new TransacaoFormViewModel { Transacao = transacao, Contas = contas }; return(View(viewModel)); } despesa = await _despesaService.ObterPorIdAsync(transacao.DespesaId.Value); var conta = await _contaService.ObterPorIdAsync(transacao.ContaId); transacao.Despesa = despesa; transacao.Conta = conta; await _transacaoService.InserirAsync(transacao); return(RedirectToAction(nameof(Gastos), despesa.Id)); }
public async Task <IActionResult> Gastos(Transacao transacao) { transacao.Id = 0; Conta conta = null; if (!ModelState.IsValid) { conta = await _contaService.ObterPorIdAsync(transacao.ContaId); transacao = _transacaoService.ObterInstanciaGastoConta(conta); return(View(transacao)); } conta = await _contaService.ObterPorIdAsync(transacao.ContaId); transacao.Conta = conta; await _transacaoService.InserirAsync(transacao); return(RedirectToAction(nameof(Gastos), conta.Id)); }
public async Task <IActionResult> Gastos(Transacao transacao) { transacao.Id = 0; if (!ModelState.IsValid) { var obj = await _fundoService.ObterPorIdAsync(transacao.FundoId.Value); transacao = _transacaoService.ObterInstanciaGastoFundo(obj); return(View(transacao)); } var fundo = await _fundoService.ObterPorIdAsync(transacao.FundoId.Value); var conta = await _contaService.ObterPorIdAsync(transacao.ContaId); transacao.Fundo = fundo; transacao.Conta = conta; await _transacaoService.InserirAsync(transacao); return(RedirectToAction(nameof(Gastos), fundo.Id)); }