public async Task <ActionResult> ViewSalesData() { try { HttpPostedFileBase salesDataFile = Request.Files.Count > 0 ? Request.Files[0] : null; IList <string> csvData = CSVHelper.ReadCSVFile(salesDataFile); if (csvData == null) { ViewBag.Errors = new[] { "Unable to read CSV file." }; } IList <VehicleDetail> vehicleDetails = CSVHelper.ConvertToModel(csvData); ViewBag.MostSoldVehicle = vehicleDetails.GroupBy(vd => vd.Vehicle).GetHighesCountGroup(); return(View("Results", vehicleDetails)); } catch (Exception ex) { Response.StatusCode = 500; return(View("Error")); } }