I have a controller that runs some calculation on data, and then I need to return the calculation to a view. I understand that I can accomplish this through the ViewBag
, but I would like to know the best practice for doing this. Are these LINQ
queries something that should just be executed in the View
?
public ViewResult Results()
{
var surveyresponsemodels = db.SurveyResponseModels.Include(
s => s.SurveyProgramModel).Include(s => s.PersonModel);
ViewBag.PatientFollowUpResult = db.SurveyResponseModels.Count(
r => r.PatientFollowUp);
ViewBag.ChangeCodingPractice = db.SurveyResponseModels.Count(
r => r.ChangeCodingPractice);
ViewBag.CountTotal = db.SurveyResponseModels.Count();
return View(surveyresponsemodels.ToList());
}