public ActionResult BondBreakdownChart(AssetBreakdown assetBreakdown)
        {
            List<string> keys = new List<string>();
            List<decimal> values = new List<decimal>();

            keys.Add("Total Domestic");
            keys.Add("Total International");

            values.Add(assetBreakdown.TotalDomesticBonds ?? 0);
            values.Add(assetBreakdown.TotalInternationalBonds ?? 0);

            ChartGenerator cg = new ChartGenerator();
            MemoryStream ms = cg.GenerateChart(keys.ToArray(), values.ToArray(), SeriesChartType.Pie, 400, 200, false, true, false);
            return File(ms.ToArray(), "image/png", "mychart.png");
        }
        public ActionResult AllAssetBreakdownChart(AssetBreakdown assetBreakdown)
        {
            List<string> keys = new List<string>();
            List<decimal> values = new List<decimal>();

            keys.Add("Total Cash");
            keys.Add("Total Real Estate");
            keys.Add("Total Stocks");
            keys.Add("Total Bonds");

            values.Add(assetBreakdown.TotalCash ?? 0);
            values.Add(assetBreakdown.TotalRealEstate ?? 0);
            values.Add(assetBreakdown.TotalStock ?? 0);
            values.Add(assetBreakdown.TotalBonds ?? 0);

            ChartGenerator cg = new ChartGenerator();
            MemoryStream ms = cg.GenerateChart(keys.ToArray(), values.ToArray(), SeriesChartType.Pie, 400, 200, false, true, false);
            return File(ms.ToArray(), "image/png", "mychart.png");
        }
 public ActionResult AssetBreakdown(AssetBreakdown assetBreakdown)
 {
     return View(assetBreakdown);
 }
        public AssetBreakdown GetAssetBreakdown(int userId)
        {
            AssetBreakdown retVal = new AssetBreakdown();

            List<Asset> userAssets = GetUserAssets(userId, AssetType.Any);
            retVal.TotalCash = userAssets.Where(a => a.AssetType == AssetType.Cash).Sum(a => a.Value);
            retVal.TotalRealEstate = userAssets.Where(a => a.AssetType == AssetType.RealEstate).Sum(a => a.Value);
            retVal.TotalDomesticStock = userAssets.Where(a => a.AssetType == AssetType.DomesticStock).Sum(a => a.Value);
            retVal.TotalInternationalStock = userAssets.Where(a => a.AssetType == AssetType.InternationalStock).Sum(a => a.Value);
            retVal.TotalDomesticBonds = userAssets.Where(a => a.AssetType == AssetType.DomesticBond).Sum(a => a.Value);
            retVal.TotalInternationalBonds = userAssets.Where(a => a.AssetType == AssetType.InternationalBond).Sum(a => a.Value);
            retVal.TotalBonds = retVal.TotalDomesticBonds + retVal.TotalInternationalBonds;
            retVal.TotalStock = retVal.TotalDomesticStock + retVal.TotalInternationalStock;

            retVal.TotalNonRealEstate = retVal.TotalAssets - retVal.TotalRealEstate;
            retVal.TotalStockAndBonds = retVal.TotalStock + retVal.TotalBonds;

            decimal[] assetPercentages = calc.CalculatePercentages(
                    new decimal[]
                    {
                        retVal.TotalCash.Value,
                        retVal.TotalRealEstate.Value,
                        retVal.TotalStock.Value,
                        retVal.TotalBonds.Value
                    });

            retVal.PercentCash = assetPercentages[0];
            retVal.PercentRealEstate = assetPercentages[1];
            retVal.PercentStock = assetPercentages[2];
            retVal.PercentBonds = assetPercentages[3];

            decimal[] stockBondPercentages = calc.CalculatePercentages(
                    new decimal[]
                    {
                        retVal.TotalBonds.Value,
                        retVal.TotalStock.Value
                    });

            retVal.PercentStockAndBondsBonds = stockBondPercentages[0];
            retVal.PercentStockAndBondsStock = stockBondPercentages[1];

            decimal[] stockPercentages = calc.CalculatePercentages(
                new decimal[]
                {
                    retVal.TotalDomesticStock.Value,
                    retVal.TotalInternationalStock.Value
                });

            retVal.PercentDomesticStock = stockPercentages[0];
            retVal.PercentInternationalStock = stockPercentages[1];

            decimal[] bondPercentages = calc.CalculatePercentages(
                new decimal[]
                {
                    retVal.TotalDomesticBonds.Value,
                    retVal.TotalInternationalBonds.Value
                });

            retVal.PercentDomesticBonds = bondPercentages[0];
            retVal.PercentInternationalBonds = bondPercentages[1];

            return retVal;
        }