public ActionResult Compare(string[] icompare) { ViewData["error"] = ""; try { if (icompare.Length == 2) { int car1, car2; int.TryParse(icompare[0], out car1); int.TryParse(icompare[1], out car2); ViewData["car1_id"] = icompare[0]; ViewData["car2_id"] = icompare[1]; DatabaseService ld = new DatabaseService(); Models.ReviewModel rm1 = ld.getReview(car1); Models.ReviewModel rm2 = ld.getReview(car2); ViewData["car1_hire"] = rm1.daily_rental_rate; ViewData["car2_hire"] = rm2.daily_rental_rate; ViewData["hire_winner"] = rm1.daily_rental_rate < rm2.daily_rental_rate ? icompare[0] : icompare[1]; ViewData["car1_engine"] = rm1.engine_power; ViewData["car2_engine"] = rm2.engine_power; ViewData["engine_winner"] = rm1.engine_power > rm2.engine_power ? icompare[0] : icompare[1]; ViewData["car1_pop"] = ld.getBookingCount(car1); ViewData["car2_pop"] = ld.getBookingCount(car2); ViewData["pop_winner"] = ld.getBookingCount(car1) > ld.getBookingCount(car2) ? icompare[0] : icompare[1]; } else { ViewData["error"] = "Please select two cars"; } } catch (Exception) { ViewData["error"] = "Please select two cars"; } return View(); }