public async Task <IActionResult> IndexTotalMonthly(string id) { await _anothersExpenseRepository.VerifyDateForDeleteDataAsync(id); var user = await _userManager.FindByIdAsync(id); var expenseFixed = await _expenseRepository.FindAllExpenseFixedByUserAsync(id); var expenseVariable = await _anothersExpenseRepository.FindAllExpenseByUserAndTypeAsync(id, 2); var expenseExtra = await _anothersExpenseRepository.FindAllExpenseByUserAndTypeAsync(id, 3); var yield = await _yieldRepository.FindAllByUserAsync(id); TotalMonthlyFormViewModel totalMensal = new TotalMonthlyFormViewModel() { TotalDespesaFixa = expenseFixed.Sum(ex => ex.Valor), TotalDespesaVariavel = expenseVariable.Sum(ex => ex.Valor), TotalDespesaExtra = expenseExtra.Sum(ex => ex.Valor), Saldo = yield.Sum(ex => ex.Valor) - (expenseFixed.Sum(ex => ex.Valor) + expenseVariable.Sum(ex => ex.Valor) + expenseExtra.Sum(ex => ex.Valor)), TotalReceita = yield.Sum(ex => ex.Valor), ValorGuardar = 0.1m * yield.Sum(ex => ex.Valor), MembroDaFamilia = (yield.Sum(ex => ex.Valor) - (expenseFixed.Sum(ex => ex.Valor) + expenseVariable.Sum(ex => ex.Valor) + expenseExtra.Sum(ex => ex.Valor))) / user.QuantidadeMembroFamilia, TotalDespesa = expenseFixed.Sum(ex => ex.Valor) + expenseVariable.Sum(ex => ex.Valor) + expenseExtra.Sum(ex => ex.Valor) }; return(View(totalMensal)); }
public async Task <IActionResult> YieldIndex(string id) { if (id == null) { return(RedirectToAction(nameof(Error), new { Message = "Id não informado" })); } var user = await _userManager.FindByIdAsync(id); if (user == null || user.Id != _userManager.GetUserId(User)) { return(RedirectToAction(nameof(Error), new { Message = "Usuario não correspondido" })); } var lista = await _yieldRepository.FindAllByUserAsync(user.Id); return(View(lista)); }