public List <SearchStudentDetailResultVM> SearchStudentDetail(SearchStudentDetailParametersVM model, string sortColumn, string sortDirection) { SqlParameter[] parameters = { new SqlParameter { ParameterName = "@TutorId", Value = model.TutorId }, new SqlParameter { ParameterName = "@Name", Value = model.Name }, new SqlParameter { ParameterName = "@Email", Value = model.Email }, new SqlParameter { ParameterName = "@PageNum", Value = model.PageNum }, new SqlParameter { ParameterName = "@PageSize", Value = model.PageSize }, new SqlParameter { ParameterName = "@SortColumn", Value = sortColumn }, new SqlParameter { ParameterName = "@SortDirection", Value = sortDirection } }; var dt = DALHelper.GetDataTableWithExtendedTimeOut("SearchStudentDetail", parameters); var students = new List <SearchStudentDetailResultVM>(); students = DALHelper.CreateListFromTable <SearchStudentDetailResultVM>(dt); return(students); }
public ActionResult SearchStudent(SearchStudentDetailParametersVM model) { try { object sortColumn = ""; object sortDirection = ""; if (model.order.Count == 0) { sortColumn = "CreatedOn"; sortDirection = "desc"; } else { sortColumn = model.columns[Convert.ToInt32(model.order[0].column)].data ?? (object)DBNull.Value; sortDirection = model.order[0].dir ?? (object)DBNull.Value; } model.PageSize = Constants.PAGESIZE; model.TutorId = LogInManager.LoggedInUser.Id; var students = userRepository.SearchStudentDetail(model, Convert.ToString(sortColumn), Convert.ToString(sortDirection)); int totalRecords = 0; var dbRecords = students.Select(m => m.TotalCount).FirstOrDefault(); if (dbRecords != 0) { totalRecords = Convert.ToInt32(dbRecords); } if (students != null && students.Count > 0) { foreach (var student in students) { if (!string.IsNullOrWhiteSpace(student.Password)) { student.Password = Utility.Utility.Decrypt(student.Password, Utility.Utility.EncryptionKey); } } } return(Json(new { IsSuccess = true, CurrentPage = model.PageNum, PageSize = Constants.PAGESIZE, TotalRecords = totalRecords, data = students }, JsonRequestBehavior.AllowGet)); } catch (Exception e) { Utility.Utility.LogError(e, "SearchStudent"); return(Json(new { IsSuccess = false, errorMessage = e.Message })); } }