public ActionResult Statistic() { List <SoldPack> spl = new List <SoldPack>(); List <SoldPack> splc = new List <SoldPack>(); var dbsoldpacks = ShopManager.GetAllSoldPacksFromUserId(UserManager.GetUserByUserEmail(User.Identity.Name).idperson); foreach (var item in dbsoldpacks) { SoldPack sp = new SoldPack(); sp.Packname = item.packname; sp.DateOfPurchase = (DateTime)item.orderdate; spl.Add(sp); } return(View(spl)); }
public ActionResult CharterColumn() { List <SoldPack> spl = new List <SoldPack>(); var dbsoldpacks = ShopManager.GetAllSoldPacksFromUserId(UserManager.GetUserByUserEmail(User.Identity.Name).idperson); foreach (var item in dbsoldpacks) { int index = spl.FindIndex(i => i.Packname == item.packname); if (index >= 0) { spl[index].Count += 1; } else { SoldPack sp = new SoldPack(); sp.Packname = item.packname; sp.Count = 1; spl.Add(sp); } } ArrayList xPackName = new ArrayList(); ArrayList yCount = new ArrayList(); var results = (from c in spl select c); results.ToList().ForEach(rs => xPackName.Add(rs.Packname)); results.ToList().ForEach(rs => yCount.Add(rs.Count)); new Chart(width: 980, height: 400, theme: UserManager.GetMyCustomTheme3()) .AddTitle("purchased packages") .AddSeries("Default", chartType: "column", xValue: xPackName, yValues: yCount) .Write("png"); return(null); }