Exemplo n.º 1
0
        // ChartJS
        public ActionResult Dashboard()
        {
            var        list                  = new FarmHubDbContext().PURCHASE_OFFER.Where(x => x.Is_Deleted == false).ToList();
            List <int> repartition           = new List <int>();
            List <int> prices                = new List <int>();
            var        productNames          = list.Select(x => x.PRODUCT.Name_Product).Distinct();
            var        quantityPurchaseOffer = list.GroupBy(x => x.PRODUCT.Name_Product).ToString();

            foreach (var item in productNames)
            {
                repartition.Add(list.Count(x => x.PRODUCT.Name_Product == item));
            }

            foreach (var item in quantityPurchaseOffer)
            {
                prices.Add(item);
            }

            ViewBag.PRODUCTNAMES = productNames;
            ViewBag.REP          = repartition.ToList();
            ViewBag.PRICES       = prices.ToList();
            return(View());
        }