public ActionResult ListSurvey(JqGridRequest request) { IList <Survey> surveyslist = service.GetAllSurveys(false); var viewModelList = (from survey in surveyslist select new SurveyGridViewModel() { Id = survey.SurveyId, Name = survey.Name, Active = survey.Active == true ? 'Y' : 'N', OpenDate = survey.OpenDate == null ? new DateTime() : survey.OpenDate.Value }).ToList(); IList <SurveyGridViewModel> sortedList = PagingSorting <SurveyGridViewModel> .getSortedList(viewModelList, request.SortingName, request.SortingOrder.ToString()); IList <SurveyGridViewModel> sortedPagedList = PagingSorting <SurveyGridViewModel> .getPagedRecords(sortedList, request.PageIndex, request.RecordsCount); int totalRecordsCount = viewModelList.Count; JqGridResponse response = new JqGridResponse() { TotalPagesCount = (int)Math.Ceiling((float)totalRecordsCount / (float)request.RecordsCount), PageIndex = request.PageIndex, TotalRecordsCount = totalRecordsCount }; response.Records.AddRange(from survey in sortedPagedList select new JqGridRecord <SurveyGridViewModel>(Convert.ToString(survey.Id), survey)); return(new JqGridJsonResult() { Data = response }); }
public ActionResult ListQuestionsGroup(JqGridRequest request) { IList <QuestionGroup> questionsGrouplist = service.GetAllQuestionGroups(); var viewModelList = (from questionsGroup in questionsGrouplist select new QuestionGroupsGridViewModel() { GroupId = questionsGroup.QuestionGroupID, Code = questionsGroup.QuestionGroupCode, Active = questionsGroup.Active == true ? 'Y' : 'N', }).ToList(); IList <QuestionGroupsGridViewModel> sortedList = PagingSorting <QuestionGroupsGridViewModel> .getSortedList(viewModelList, request.SortingName, request.SortingOrder.ToString()); IList <QuestionGroupsGridViewModel> sortedPagedList = PagingSorting <QuestionGroupsGridViewModel> .getPagedRecords(sortedList, request.PageIndex, request.RecordsCount); int totalRecordsCount = viewModelList.Count; JqGridResponse response = new JqGridResponse() { TotalPagesCount = (int)Math.Ceiling((float)totalRecordsCount / (float)request.RecordsCount), PageIndex = request.PageIndex, TotalRecordsCount = totalRecordsCount }; response.Records.AddRange(from questionsgroup in sortedPagedList select new JqGridRecord <QuestionGroupsGridViewModel>(Convert.ToString(questionsgroup.GroupId), questionsgroup)); return(new JqGridJsonResult() { Data = response }); }
public ActionResult ListQuestions(JqGridRequest request, int questionsGroupId = 0) { IList <Question> questionslist = service.getAllQuestionsOf(questionsGroupId, false); var viewModelList = (from question in questionslist select new QuestionsGridViewModel() { QuestionId = question.QuestionID, Quetion = question.QuestionText, Order = question.Order, Numeric = question.Numeric, // ? 'Y':'N', Active = question.Active, // ? 'Y' : 'N', }).ToList(); IList <QuestionsGridViewModel> sortedList = PagingSorting <QuestionsGridViewModel> .getSortedList(viewModelList, request.SortingName, request.SortingOrder.ToString()); IList <QuestionsGridViewModel> sortedPagedList = PagingSorting <QuestionsGridViewModel> .getPagedRecords(sortedList, request.PageIndex, request.RecordsCount); int totalRecordsCount = viewModelList.Count; JqGridResponse response = new JqGridResponse() { TotalPagesCount = (int)Math.Ceiling((float)totalRecordsCount / (float)request.RecordsCount), PageIndex = request.PageIndex, TotalRecordsCount = totalRecordsCount }; response.Records.AddRange(from question in sortedPagedList select new JqGridRecord <QuestionsGridViewModel>(Convert.ToString(question.QuestionId), question)); return(new JqGridJsonResult() { Data = response }); }
public ActionResult ListSelectedStudents(JqGridRequest request, int id = 0) { IList <SurveyStudent> selectedStudents = new List <SurveyStudent>(); if (Session["selectedStudents"] != null) { string[][] studentsarray = (string[][])Session["selectedStudents"]; for (int i = 0; i < studentsarray.Count(); i++) { selectedStudents.Add(new SurveyStudent() { StudentNo = Convert.ToInt32(studentsarray[i][0]), LastName = studentsarray[i][1], FirstName = studentsarray[i][2], EnrollmentId = Convert.ToInt32(studentsarray[i][3]) }); } } if (id != 0) { selectedStudents = service.getStudentsBySurveyId(id); } var viewModelList = from student in selectedStudents select new SelectedStudentsGridViewModel { EnrollmentId = student.EnrollmentId, StudentId = student.StudentNo, LastName = student.LastName, FirstName = student.FirstName }; IList <SelectedStudentsGridViewModel> sortedList = PagingSorting <SelectedStudentsGridViewModel> .getSortedList(viewModelList.ToList(), request.SortingName, request.SortingOrder.ToString()); IList <SelectedStudentsGridViewModel> sortedPagedList = PagingSorting <SelectedStudentsGridViewModel> .getPagedRecords(sortedList, request.PageIndex, request.RecordsCount); int totalRecordsCount = viewModelList.Count(); JqGridResponse response = new JqGridResponse() { TotalPagesCount = (int)Math.Ceiling((float)totalRecordsCount / (float)request.RecordsCount), PageIndex = request.PageIndex, TotalRecordsCount = totalRecordsCount }; response.Records.AddRange(from studentRecord in sortedPagedList select new JqGridRecord <SelectedStudentsGridViewModel>(Convert.ToString(studentRecord.StudentId), studentRecord)); return(new JqGridJsonResult() { Data = response }); }
public ActionResult ListFilteredStudents(JqGridRequest request, int surveyId = 0, string StudentStatusId = "", string ProgramsId = "", string TermsId = "", string StudentGroupId = "", string SessionsId = "") { StudentStatusId = string.IsNullOrEmpty(StudentStatusId) ? "1" : StudentStatusId; ProgramsId = string.IsNullOrEmpty(ProgramsId) ? "24" : ProgramsId; TermsId = string.IsNullOrEmpty(TermsId) ? "336" : TermsId; StudentGroupId = string.IsNullOrEmpty(StudentGroupId) ? "40" : StudentGroupId; SessionsId = string.IsNullOrEmpty(SessionsId) ? "A" : SessionsId; IList <SurveyStudent> surveysStudentlist = service.getFilteredStudents(surveyId, Convert.ToInt32(StudentStatusId), Convert.ToInt32(ProgramsId), Convert.ToInt32(TermsId), Convert.ToInt32(StudentGroupId), SessionsId); var viewModelList = (from surveyStudent in surveysStudentlist select new SurveyStudentGridViewModel() { SurveyStudentId = surveyStudent.StudentNo, FirstName = surveyStudent.FirstName, LastName = surveyStudent.LastName, StartDate = surveyStudent.TermStartDate, Program = surveyStudent.ProgramCode, Status = surveyStudent.StudentStatus, EnrollmentId = surveyStudent.EnrollmentId }).ToList(); IList <SurveyStudentGridViewModel> sortedList = PagingSorting <SurveyStudentGridViewModel> .getSortedList(viewModelList, request.SortingName, request.SortingOrder.ToString()); IList <SurveyStudentGridViewModel> sortedPagedList = PagingSorting <SurveyStudentGridViewModel> .getPagedRecords(sortedList, request.PageIndex, request.RecordsCount); int totalRecordsCount = viewModelList.Count; JqGridResponse response = new JqGridResponse() { TotalPagesCount = (int)Math.Ceiling((float)totalRecordsCount / (float)request.RecordsCount), PageIndex = request.PageIndex, TotalRecordsCount = totalRecordsCount }; response.Records.AddRange(from survey in sortedPagedList select new JqGridRecord <SurveyStudentGridViewModel>(Convert.ToString(survey.SurveyStudentId), survey)); return(new JqGridJsonResult() { Data = response }); }