public ActionResult EnCokSatisYapilanBesUrun() { List <EnCokSatilanUrunler> urunler = new List <EnCokSatilanUrunler>(); using (var db = new EticaretContext()) { var satilanurunler = db.Encoksatisyapilanurunler(); foreach (var u in satilanurunler) { urunler.Add(new EnCokSatilanUrunler { UrunAdi = u.Urun_Adi, Adet = (int)u.adet, UrunId = (int)u.UrunId }); } } Chart chart = new Chart(500, 400); chart.AddTitle("En Çok Satılan 5 Ürün"); chart.AddLegend("Ürünler"); chart.DataBindTable(dataSource: urunler, xField: "UrunAdi"); chart.DataBindCrossTable(dataSource: urunler, groupByField: "UrunAdi", xField: "UrunAdi", yFields: "Adet"); return(View(chart)); }
public ActionResult EnCokSatilanUrunler(int page = 1, int pageSize = 12) { List <tbl_Urun> urunler = new List <tbl_Urun>(); using (var db = new EticaretContext()) { var satilanurunler = db.Encoksatisyapilanurunler(); foreach (var u in satilanurunler) { var encoksatan = uow.UrunRepository.GetById((int)u.UrunId); urunler.Add(encoksatan); } } PagedList <tbl_Urun> encoksatanurun = new PagedList <tbl_Urun>(urunler, page, pageSize); return(View("Anasayfa", encoksatanurun)); }