public ActionResult HostelTransaction(StudentSearchViewModel userInput) { TransactionHelper helper = new TransactionHelper(); // make an attempt to find the student and display the form, if not possible, show error HostelTransactionViewModel viewModel = helper.ConstructViewModelForHostelTransaction(userInput.bid); if (viewModel != null) { // generate the list of account heads to be displayed and add it to the view bag ViewBag.acHeadList = new SelectList(helper.GetAccountHeads(), "id", "val"); // generate the list of payment types to be displayed and add it to the view bag ViewBag.paymentTypeList = new SelectList(helper.GetPaymentTypes(false), "id", "val"); //generate the list of academic years to be displayed and add it to the view bag ViewBag.academicYearList = new SelectList(helper.GetValidAcademicYears(viewModel.year), DateTime.Now.Year + ""); // display the form return(PartialView("_AddHostelTransation", viewModel)); } else { return(Content("Student not found")); } }