private void gerarListaCompletaReceita(ref ResumoMensalModel resumoMensal)
        {
            List <ResumoCategoriaMesModel> lista = gerarListaReceita(resumoMensal.sMesAno);
            double dTotal = 0;

            foreach (ResumoCategoriaMesModel exp in lista)
            {
                dTotal += exp.dValor;
            }
            resumoMensal.dTotalReceita = dTotal;
        }
        private ResumoMensalModel criaResumoMensal(string sMesAno)
        {
            ResumoMensalModel model = new ResumoMensalModel();

            model.lstCategoriaGastos = new List <HomeResumoCategoriaModel>();
            model.dTotalReceita      = 0;
            model.dTotalDespesa      = 0;
            model.sMesAno            = sMesAno;
            model.sMesAnoAnterior    = (new DateTime(int.Parse(sMesAno.Substring(2, 4)), int.Parse(sMesAno.Substring(0, 2)), 1)).AddMonths(-1).ToString("MMyyyy");
            model.sMesAnoPosterior   = (new DateTime(int.Parse(sMesAno.Substring(2, 4)), int.Parse(sMesAno.Substring(0, 2)), 1)).AddMonths(1).ToString("MMyyyy");
            gerarListaCompletaDespesa(ref model);
            gerarListaCompletaReceita(ref model);
            model.dTotalDiferenca = model.dTotalReceita - model.dTotalDespesa;
            return(model);
        }
        private void gerarListaCompletaDespesa(ref ResumoMensalModel resumoMensal)
        {
            List <ResumoCategoriaMesModel> listaDetalhada = gerarListaDespesa(resumoMensal.sMesAno);

            double dTotal = 0;
            Dictionary <string, double> dcExpense = new Dictionary <string, double>();

            foreach (ResumoCategoriaMesModel exp in listaDetalhada)
            {
                if (!dcExpense.ContainsKey(exp.sCategoryID))
                {
                    dcExpense.Add(exp.sCategoryID, 0);
                }
                dcExpense[exp.sCategoryID] += exp.dValor;
                dTotal += exp.dValor;
            }

            dcExpense = dcExpense.OrderByDescending(d => d.Value).ToDictionary(x => x.Key, x => x.Value);;
            int iTotElementos = dcExpense.Count;

            foreach (var hr in dcExpense)
            {
                HomeResumoCategoriaModel homeResumo = new HomeResumoCategoriaModel();
                homeResumo.sMesAno      = resumoMensal.sMesAno;
                homeResumo.dValor       = hr.Value;
                homeResumo.sCategoriaID = hr.Key;
                homeResumo.sDescricao   = categoryBusiness.Get.FirstOrDefault(c => c.sID == hr.Key).descricao;
                homeResumo.dPercentual  = (hr.Value * 100) / dTotal;
                resumoMensal.lstCategoriaGastos.Add(homeResumo);

                if (string.IsNullOrEmpty(resumoMensal.sLstCategoriaGastos))
                {
                    resumoMensal.sLstCategoriaGastos = homeResumo.sDescricao + "|&" + Math.Round(homeResumo.dPercentual, 2);
                }
                else
                {
                    resumoMensal.sLstCategoriaGastos += "|&" + homeResumo.sDescricao + "|&" + Math.Round(homeResumo.dPercentual, 2);
                }
            }
            resumoMensal.dTotalDespesa = dTotal;
        }