public ActionResult IndexPopulate() { Category.DeleteAll(); Buyer.DeleteAll(); Populate.PopulateDatabase(); Dictionary <string, object> model = new Dictionary <string, object> { }; Buyer buyer = Buyer.Find(0); List <Product> featured = Product.GetAll(); Random rnd = new Random(); List <Product> newFeatured = new List <Product>() { }; if (featured.Count > 0) { for (var i = 0; i < 4; i++) { newFeatured.Add(featured[rnd.Next(0, (featured.Count - 1))]); } var featuredProduct = featured[rnd.Next(0, (featured.Count - 1))]; model.Add("featured", featuredProduct); } model.Add("categories", Category.GetAll()); model.Add("buyer", buyer); model.Add("products", newFeatured); return(View("Index", model)); }