public static List <RestaurantReviewGraphs> ReviewedGraphsTopTen() { List <RestaurantReviewGraphs> restaurants = new List <RestaurantReviewGraphs>(); string name; string info; decimal IY; int restID; string query = $"select Avg(`ReviewScore`) from RestaurantReviews order by AVG('ReviewScore') ACS limit 10;"; DataTable Reviews = restaurantReviewsData.RestaurauntData(query); foreach (DataRow row in Reviews.Rows) { int.TryParse(row["RestaurantId"].ToString(), out restID); decimal.TryParse(row["ReviewScore"].ToString(), out IY); DataTable dataTable = restaurantReviewsData.RestaurauntData($@"select * from RestaurantProfiles where id = {restID};"); foreach (DataRow rrow in dataTable.Rows) { name = rrow["id"].ToString(); info = ""; info += $"{rrow["RestaurantName"].ToString()}\r\n" + $"{rrow["Address"].ToString()}\r\n" + $"{rrow["Phone"].ToString()}\r\n" + $"{rrow["Price"].ToString()}\r\n"; RestaurantReviewGraphs Add = new RestaurantReviewGraphs(name, info, IY); restaurants.Add(Add); } } return(restaurants); }
public static RestaurantReviewGraphs[] ReviewGraphs() { List <RestaurantReviewGraphs> restaurants = new List <RestaurantReviewGraphs>(); for (int i = 1; i <= 100; i++) { string info = ""; string restID; DataTable dataTable = restaurantReviewsData.RestaurauntData($@"select * from RestaurantProfiles where id = { i };"); foreach (DataRow rrow in dataTable.Rows) { decimal IY = 0; info = ""; info += $"{rrow["RestaurantName"].ToString()}\r\n" + $"{rrow["Address"].ToString()}\r\n" + $"{rrow["Phone"].ToString()}\r\n" + $"{rrow["Price"].ToString()}\r\n"; string query = $@"select Avg(`ReviewScore`) from RestaurantReviews where `RestaurantId` = {i};"; DataTable Reviews = restaurantReviewsData.RestaurauntData(query); foreach (DataRow row in Reviews.Rows) { restID = rrow["id"].ToString(); decimal.TryParse(row["Avg(`ReviewScore`)"].ToString(), out IY); } string name = rrow["id"].ToString(); RestaurantReviewGraphs Add = new RestaurantReviewGraphs(name, info, IY); restaurants.Add(Add); i++; } } RestaurantReviewGraphs[] graphs = restaurants.ToArray(); return(graphs); }