public ActionResult Create(int?id) { var organisationId = UserOrganisationId; var centreId = UserCentreId; id = id ?? 0; var enquiry = _nidanBusinessService.RetrieveEnquiry(organisationId, id.Value, e => true); var paymentModes = _nidanBusinessService.RetrievePaymentModes(organisationId, e => true); var interestedCourseIds = enquiry.EnquiryCourses.Select(e => e.CourseId).ToList(); var courses = _nidanBusinessService.RetrieveCourses(organisationId, p => true).Where(e => interestedCourseIds.Contains(e.CourseId)); var batchTimePrefers = _nidanBusinessService.RetrieveBatchTimePrefers(organisationId, e => true); var courseInstallments = _nidanBusinessService.RetrieveCentreCourseInstallments(organisationId, centreId).Items.Select(e => e.CourseInstallment).ToList(); var counsellingData = _nidanBusinessService.RetrieveCounsellings(organisationId, e => e.EnquiryId == enquiry.EnquiryId).Items.FirstOrDefault(); var counsellingCourse = _nidanBusinessService.RetrieveCourses(organisationId, e => true).Where(e => e.CourseId == counsellingData?.CourseOfferedId); var viewModel = new RegistrationViewModel { PaymentModes = new SelectList(paymentModes, "PaymentModeId", "Name"), Courses = new SelectList(courses, "CourseId", "Name"), BatchTimePrefers = new SelectList(batchTimePrefers, "BatchTimePreferId", "Name"), Enquiry = enquiry, StudentCode = enquiry.StudentCode, EnquiryId = enquiry.EnquiryId, CourseInstallments = new SelectList(courseInstallments, "CourseInstallmentId", "Name"), CounsellingCourse = new SelectList(counsellingCourse, "CourseId", "Name") }; return(View(viewModel)); }