/// <summary> /// Process the sorting parameters and create the array of sort nodes that will be used by query processors /// </summary> /// <param name="processedQueryParameters"></param> /// <param name="castGeneralQueryParameters"></param> private void ProcessSortingParams(QueryParameters processedQueryParameters, JQueryDataTableParams castGeneralQueryParameters) { // Reference all the bound property names as sent from the client var boundDataProperties = castGeneralQueryParameters.amDataProp; var sortPriority = 0; // Reference the sorting directions array var sortingDirections = castGeneralQueryParameters.asSortDir; foreach (var columBeingSorted in castGeneralQueryParameters.aiSortCol) { var sortNode = new SortNode { SortTarget = boundDataProperties[columBeingSorted], SortPriority = sortPriority++, SortDirection = GetSortDirection(sortingDirections, columBeingSorted) == "asc" ? SortDirection.Asc : SortDirection.Desc }; // Set the sorting target processedQueryParameters.SortNodes.Add(sortNode); } }
// [System.Web.Http.HttpPost] public ActionResult GetBookspost(JQueryDataTableParams param) { // int i = 1; if (Request.Form["action"] == "edit") { return(Json(new { success = true, responseText = 1000, responseCode = "Success" })); } JsonResult JsonResult = new JsonResult(); try { int recFilter = db.BookDB.Count(); //var displayedMembers = db.BookDB.ToList().Skip(param.iDisplayStart).Take(param.iDisplayLength); if (param.iDisplayLength != -1) { var displayedMembers = (from s in db.BookDB where s.Title == "Title12" select s).ToList().Skip(param.iDisplayStart).Take(param.iDisplayLength); JsonResult = Json(new { sEcho = param.sEcho, iTotalRecords = recFilter, iTotalDisplayRecords = recFilter, aaData = displayedMembers }, JsonRequestBehavior.AllowGet); } else { var displayedMembers = (from s in db.BookDB where s.Isbn == "Isbn12" select s).ToList(); JsonResult = Json(new { sEcho = param.sEcho, iTotalRecords = recFilter, iTotalDisplayRecords = recFilter, aaData = displayedMembers }, JsonRequestBehavior.AllowGet); } } catch (Exception ex) { // Info Console.Write(ex); } // Return info. return(JsonResult); }
public JsonResult GetAllByFilter(JQueryDataTableParams param, string filtros) { try { AuthUser authUser = Authenticator.AuthenticatedUser; NameValueCollection filtersValues = HttpUtility.ParseQueryString(filtros); filtersValues["UserId"] = "-1"; if (authUser.Role.Code != Constants.ROLE_ADMIN && authUser.Role.Code != Constants.ROLE_IT_SUPPORT) { filtersValues["UserId"] = Convert.ToString(authUser.Id); } var payments = _paymentService.FilterBy(filtersValues, param.iDisplayStart, param.iDisplayLength); IList <PaymentViewModel> dataResponse = new List <PaymentViewModel>(); foreach (var payment in payments.Item1) { PaymentViewModel resultData = new PaymentViewModel { Id = Convert.ToString(payment.Id), OrderId = payment.OrderId, Amount = payment.Amount, PaymentMethod = payment.Method, ProviderId = payment.ProviderId, Status = payment.Status, CreationDate = payment.CreationDate.ToString(Constants.DATE_FORMAT_CALENDAR), ConfirmationDate = payment.ConfirmationDate.HasValue?payment.ConfirmationDate.Value.ToString(Constants.DATE_FORMAT_CALENDAR) :"", User = payment.User.Email }; dataResponse.Add(resultData); } return(Json(new { success = true, param.sEcho, iTotalRecords = dataResponse.Count(), iTotalDisplayRecords = payments.Item2, aaData = dataResponse }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(new JsonResult { Data = new { Mensaje = new { title = "Error", message = ex.Message } }, JsonRequestBehavior = JsonRequestBehavior.AllowGet, MaxJsonLength = Int32.MaxValue }); } }
/// <summary> /// Get User Paging Data /// </summary> /// <returns></returns> public IActionResult GetUserPageData(JQueryDataTableParams jqueryTableParams) { var allUsers = _userManager.Users.ToList(); //GET ALL if (jqueryTableParams.iDisplayLength == -1) { jqueryTableParams.iDisplayLength = allUsers.Count; } var pageUserData = _userManager.Users.Skip(jqueryTableParams.iDisplayStart).Take(jqueryTableParams.iDisplayLength).ToList(); PageResult <ApplicationUser> pageResult = new PageResult <ApplicationUser>(jqueryTableParams.sEcho, allUsers.Count, pageUserData); return(Json(pageResult)); }
/// <summary> /// Get Role Paging Data /// </summary> /// <returns></returns> public IActionResult GetRolePageData(JQueryDataTableParams jqueryTableParams) { //HttpRequest rq = Request; //StreamReader srRequest = new StreamReader(rq.Body); //String strReqStream = srRequest.ReadToEnd(); //JQueryDataTableParams jqueryTableParam = JsonHandler.UnJson<JQueryDataTableParams>(strReqStream); var allRoles = _roleManager.Roles.ToList(); //GET ALL if (jqueryTableParams.iDisplayLength == -1) { jqueryTableParams.iDisplayLength = allRoles.Count; } var pageRoleData = _roleManager.Roles.Skip(jqueryTableParams.iDisplayStart).Take(jqueryTableParams.iDisplayLength).ToList(); PageResult <IdentityRole> pageResult = new PageResult <IdentityRole>(jqueryTableParams.sEcho, allRoles.Count, pageRoleData); return(Json(pageResult)); }
public JsonResult GetAllByFilter(JQueryDataTableParams param, string filtros) { try { NameValueCollection filtersValues = HttpUtility.ParseQueryString(filtros); var results = _userService.FilterBy(filtersValues, param.iDisplayStart, param.iDisplayLength); IList <UserData> dataResponse = new List <UserData>(); foreach (var user in results.Item1) { UserData userData = new UserData(); userData.Name = user.FirstName + " " + user.LastName; userData.Email = user.Email; userData.RoleName = user.Role.Name; userData.CreatedAt = user.CreatedAt; userData.UpdatedAt = user.UpdatedAt; userData.Status = user.Status; userData.Uuid = user.Uuid; userData.LastLoginAt = user.LastLoginAt; dataResponse.Add(userData); } return(Json(new { success = true, param.sEcho, iTotalRecords = dataResponse.Count(), iTotalDisplayRecords = results.Item2, aaData = dataResponse }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(new JsonResult { Data = new { Mensaje = new { title = "Error", message = ex.Message } }, JsonRequestBehavior = JsonRequestBehavior.AllowGet, MaxJsonLength = Int32.MaxValue }); } }
public ActionResult ProcessDataTableRequest(JQueryDataTableParams dataTablesParam, FilterScaffoldModel <Document> filters) { // Profule the Document Querying functionality using mini profiler var profiler = MiniProfiler.Current; // Get the query params and process the query for the document queryable var queryParams = _documentParamsProcessor.ProcessParameters(dataTablesParam, filters); // Get and Profile the Documents Queryable collection var documents = _documentRepository.ReadAllAsQueryable(); QueryResult <Document> queryProcessResult; using (profiler.Step("Document Query Processing")) { queryProcessResult = _documentQueryProcessor.ProcessQuery(documents, queryParams); } // Get and Profile The execution of the queryable collection for documents List <Document> queriedDocuments; using (profiler.Step("Document Query Execution")) { queriedDocuments = queryProcessResult.ProcessedData.ToList(); } var mappedDocuments = queriedDocuments.Select(Mapper.Map <AdminDocumentGridViewModel>).ToList(); JQueryDataTableResult jQueryResult = new JQueryDataTableResult() { aaData = mappedDocuments, iTotalDisplayRecords = queryProcessResult.FilteredCount, iTotalRecords = queryProcessResult.TotalCount, sEcho = dataTablesParam.sEcho }; return(Json(jQueryResult, JsonRequestBehavior.AllowGet)); }
public JsonResult ObtenerRoles(JQueryDataTableParams param, string filtros) { try { var roles = _roleService.ObtenerRoles(filtros); IList <RoleData> UsuariosResponse = new List <RoleData>(); foreach (var rol in roles) { RoleData userData = new RoleData(); userData.Name = rol.Name; userData.Description = rol.Description; userData.CreatedAt = rol.CreatedAt; userData.UpdatedAt = rol.UpdatedAt; userData.Status = rol.Status; userData.Uuid = rol.Uuid; UsuariosResponse.Add(userData); } return(Json(new { success = true, sEcho = param.sEcho, iTotalRecords = UsuariosResponse.Count(), iTotalDisplayRecords = 10, aaData = UsuariosResponse }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(new JsonResult { Data = new { Mensaje = new { title = "Error", message = ex.Message } }, JsonRequestBehavior = JsonRequestBehavior.AllowGet, MaxJsonLength = Int32.MaxValue }); } }
/// <summary> /// Sets the paging parameters, Skip and Take on the QueryParameters Common object from the processed/ing JQueryDAtaTableParams object. /// </summary> /// <param name="processedParameters"></param> /// <param name="generalQueryParameters"></param> private void ProcessPagingParams(QueryParameters processedParameters, JQueryDataTableParams generalQueryParameters) { processedParameters.Skip = generalQueryParameters.iDisplayStart; processedParameters.Take = generalQueryParameters.iDisplayLength; }