/// <summary> /// Method to get the device list with search text /// </summary> /// <param name="searchText"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="sortField"></param> /// <param name="sortDirection"></param> /// <returns></returns> public JsonResult GetDeviceList(string searchText, int pageIndex, int pageSize, string sortField, string sortDirection) { List<DeviceModel> deviceModels; using (JetstreamClient objMainServiceClient = new JetstreamClient()) { var deviceList = objMainServiceClient.GetFilterDeviceList(searchText); SetDeviceLocation(deviceList); SortingPagingInfo info = new SortingPagingInfo { SortField = sortField, SortDirection = sortDirection, }; deviceModels = ApplySorting(info, deviceList).Skip(pageIndex * pageSize).Take(pageSize).ToList(); } return Json(new { deviceModels }, JsonRequestBehavior.AllowGet); }
public ActionResult DeviceDetail(SortingPagingInfo info) { StringBuilder objStringBuilderError = new StringBuilder(); try { if (Session["UserName"] != null) { IEnumerable<DeviceModel> lstDeviceDetail; using (JetstreamClient objMainServiceClient = new JetstreamClient()) { lstDeviceDetail = objMainServiceClient.GetFilterDeviceList(info.SearchText); } SetDeviceLocation(lstDeviceDetail); lstDeviceDetail = ApplySorting(info, lstDeviceDetail).Take(Constants.PagingPageSize); ViewBag.SortingPagingInfo = info; ViewBag.SortField = info.SortField; return View("DeviceDetail", lstDeviceDetail); } else { return RedirectToAction("UserLogin", "Login"); } } catch (FaultException<ServiceData> fex) { objStringBuilderError.AppendLine("In method : DeviceDetail(SortingPagingInfo info) :: DeviceController"); objStringBuilderError.AppendFormat("ErrorMessage::{0} {1}", fex.Detail.ErrorMessage, Environment.NewLine); objStringBuilderError.AppendFormat("ErrorDetails::{0} {1}", Environment.NewLine, fex.Detail.ErrorDetails); SaveLogger.SaveLoggerError(objStringBuilderError.ToString()); return View("Error"); } catch (Exception ex) { objStringBuilderError.AppendLine("In method : DeviceDetail(SortingPagingInfo info) :: DeviceController"); objStringBuilderError.AppendFormat("ErrorMessage::{0} {1}", ex.Message, Environment.NewLine); objStringBuilderError.AppendFormat("ErrorDetails::{0} {1}", Environment.NewLine, ex.ToString()); SaveLogger.SaveLoggerError(objStringBuilderError.ToString()); return View("Error"); } }