public ActionResult List_GetProperties([DataSourceRequest]DataSourceRequest datarequest, string postCode, int? beds) { var request = new PropertyListRequestDto() { Beds = beds, PostCode = postCode }; var response = _tenantService.GetAvailablePropertiesForList(request); foreach (var item in response.Items) { if (item.PropertyImageId.HasValue && item.PropertyImageId.Value != Guid.Empty) { item.ImagePath = $"{ConfigurationManager.AppSettings["CDNPath"]}{item.PropertyId}/{item.PropertyImageId.Value}.jpg"; } else { item.ImagePath = $"{ConfigurationManager.AppSettings["CDNPath"]}/6B1E5AD9-8731-4858-AF3B-07C7B593E905.jpg"; } } var result = new DataSourceResult() { Data = response != null ? response.Items : null, Total = response != null ? response.Count : 0 }; return Json(result); }
/// <summary> /// 查询系统用户列表执行方法 /// </summary> /// <param name="request"> /// 数据源请求信息对象 /// </param> /// <returns> /// 执行方法结果 /// </returns> public ActionResult QueryLog([DataSourceRequest] DataSourceRequest request) { this.systemLogService = new SystemLogService(); int pageCount; int totalCount; if (request.Page <= 0) { request.Page = 1; } var paging = new Paging("[System_Log]", null, "ID", null, request.Page, request.PageSize); var list = this.systemLogService.Query(paging, out pageCount, out totalCount); if (list == null) { return this.View(); } var modelList = new List<System_Log>(); foreach (var systemRole in list) { modelList.Add(DataTransfer.Transfer<System_Log>(systemRole, typeof(System_Log))); } var result = new DataSourceResult { Data = modelList, Total = totalCount }; return this.Json(result, JsonRequestBehavior.AllowGet); }
public ActionResult Orders_Read([DataSourceRequest]DataSourceRequest request) { IQueryable<Order> orders = new NorthwindEntities().Orders; if (request.Sorts.Any()) { foreach (SortDescriptor sortDescriptor in request.Sorts) { if (sortDescriptor.SortDirection == ListSortDirection.Ascending) { switch (sortDescriptor.Member) { case "OrderID": orders = orders.OrderBy(order => order.OrderID); break; case "ShipAddress": orders = orders.OrderBy(order => order.ShipAddress); break; } } else { switch (sortDescriptor.Member) { case "OrderID": orders = orders.OrderByDescending(order => order.OrderID); break; case "ShipAddress": orders = orders.OrderByDescending(order => order.ShipAddress); break; } } } } else { // EF can't page unsorted data orders = orders.OrderBy(o => o.OrderID); } var total = orders.Count(); // Apply paging if (request.Page > 0) { orders = orders.Skip((request.Page - 1) * request.PageSize); } orders = orders.Take(request.PageSize); var result = new DataSourceResult() { Data = orders, // Process data (paging and sorting applied) Total = total // Total number of records }; return Json(result); }
public JsonResult GetPropertyImages(Guid propertyId) { var dtos = _landlordService.GetPropertyImagesForProperty(propertyId); var result = new DataSourceResult() { Data = dtos, Total = dtos.Count }; return Json(result); }
public ActionResult Books([DataSourceRequest] DataSourceRequest request) { IEnumerable<Book> books = KendoBooksController._library; books = books.Skip((request.Page - 1) * request.PageSize); books = books.Take(request.PageSize); var dataSourceResult = new DataSourceResult() { Data = books.ToList(), Total = KendoBooksController._library.Count }; return Json(dataSourceResult, JsonRequestBehavior.AllowGet); }
public ActionResult TvShows_Read([DataSourceRequest] DataSourceRequest request) { DataSourceResult result = new DataSourceResult(); var user = _membershipService.GetUser(User.Identity.Name); var shows = _tvService.GetUserTvShows(user.User.Key); var showModels = Mapper.Map<IEnumerable<TvShowDto>>(shows); result = showModels.ToDataSourceResult(request); foreach (var d in result.Data) { ((TvShowDto) d).EpisodeCount = _tvService.CountTvShowEpisodes(((TvShowDto) d).Key, user.User.Key); } return Json(result); }
public ActionResult GridGet([DataSourceRequest]DataSourceRequest request) { var data = new DataSourceResult(); var list = _subjectinfoInfoService.GetList(request.Page - 1, request.PageSize); if (list != null) { //data = list.ToModel<SubjectInfo, SubjectInfoModel>(); request.Page = 1; data = list.Select(o => o.ToAdminModel()).ToDataSourceResult(request); data.Total = list.Total; } return new JsonResult() { Data = data }; }
public ActionResult GetNextCustomers([DataSourceRequest] DataSourceRequest request) { Guard.Against<ArgumentNullException>(request == null, "Grid request cannot be null when loading customers"); GridResult<IEnumerable<Customer>> result = customerService.Execute(request.Page, request.PageSize); Guard.Against<ArgumentNullException>(result == null, "Result cannot be null when loading customers using AJAX"); DataSourceResult dataSource = new DataSourceResult { Data = result.Entity, Total = result.TotalRecords }; return Json(dataSource); }
public ActionResult AdminLadders_Read([DataSourceRequest]DataSourceRequest request) { // Get User Identity // Get Admin Identity IEnumerable<Ladder> ladders = LadderCollection.LoadAll(); DataSourceResult result = new DataSourceResult(); result = ladders.ToDataSourceResult(request, ladder => new AdminLaddersViewModel { Id = ladder.Id, Name = ladder.Name, Description = ladder.Description, CreationDate = ladder.CreationDate, isActive = Convert.ToBoolean(ladder.isActive), MaxPlayers = ladder.MaxPlayers, MinAge = ladder.MinAge, MaxAge = ladder.MaxAge, MinRating = ladder.MinRating, MaxRating = ladder.MaxRating, UpperChallengeLimit = ladder.UpperChallengeLimit, LowerChallengeLimit = ladder.LowerChallengeLimit, MaxPendingChallenges = ladder.MaxPendingChallenges, MaxQueuedChallenges = ladder.MaxQueuedChallenges, MaxInactiveDays = ladder.MaxInactiveDays, Penalties = ladder.Penalties, InactivityPointLoss = ladder.InactivityPointLoss, MinReqChallenges = ladder.MinReqChallenges, MinMatchDays = ladder.MinMatchDays, MinMatchPointLoss = ladder.MinMatchPointLoss, IgnoreAction = Convert.ToBoolean(ladder.IgnoreAction), IgnorePointLoss = Convert.ToBoolean(ladder.IgnorePointLoss), MaxIgnoreDays = ladder.MaxIgnoreDays, ChallengeDecline = Convert.ToBoolean(ladder.ChallengeDecline), MaxDeclines = ladder.MaxDeclines, DeclineDays = ladder.DeclineDays, DeclinePointLoss = ladder.DeclinePointLoss, ForfeitPointLoss = ladder.ForfeitPointLoss }); return Json(result); }
// POST api/Products public HttpResponseMessage PostProduct(Product product) { if (ModelState.IsValid) { db.Products.Add(product); db.SaveChanges(); DataSourceResult result = new DataSourceResult { Data = new[] { product }, Total = 1 }; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, result); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = product.ProductID })); return response; } else { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } }
public ActionResult Process_Filter([DataSourceRequest] DataSourceRequest request) { GridFilter filter = request.GetFilter(); IPageOfList<ProcessDef> data = repository.FindAll<ProcessDef>(filter.Parameters, filter.SortCommand ?? "order by CreateTime desc", filter.PageInfo); var result = new DataSourceResult() { Data = data.Select(o => new ProcessDefModel() { ID = o.ID, CategoryID = o.CategoryID, CurrentFlag = o.CurrentFlag == 1 ? "是" : "否", IsActive = o.IsActive == 1 ? "是" : "否", Name = o.Name, Text = o.Text, Version = o.Version, CurrentState = o.CurrentState.Cast<ProcessStatus>(ProcessStatus.Candidate).GetRemark() }), Total = (int)filter.PageInfo.ItemCount }; return Json(result); }
public ActionResult List([DataSourceRequest] DataSourceRequest request, string keyword = null) { int _total = 0; SortDescriptor sortDescriptor = (request.Sorts != null && request.Sorts.Count > 0) ? request.Sorts.FirstOrDefault() : new SortDescriptor("CreatedDate", ListSortDirection.Descending); sortDescriptor.Member = sortDescriptor.Member ?? "Name"; Func<IQueryable<Product>, IOrderedQueryable<Product>> order; Expression<Func<Product, bool>> filter = x => x.IsActive == true; if (!string.IsNullOrEmpty(keyword)) { filter = x => x.Name.Contains(keyword); } var data = new List<Product>(); switch (sortDescriptor.Member) { case "Name": if (sortDescriptor.SortDirection == ListSortDirection.Ascending) { order = x => x.OrderBy(y => y.Name); } else { order = x => x.OrderByDescending(y => y.Name); } break; default: if (sortDescriptor.SortDirection == ListSortDirection.Ascending) { order = x => x.OrderBy(y => y.CreatedDate); } else { order = x => x.OrderByDescending(y => y.CreatedDate); } break; } data = _productService.Select(filter, order, null, request.Page, request.PageSize).ToList(); var products = new List<ProductModel>(); AutoMapper.Mapper.CreateMap<Product, ProductModel>(); products = AutoMapper.Mapper.Map<List<Product>, List<ProductModel>>(data); _total = _productService.Select(filter, order, null, null, null).Count(); ViewBag.Total = _total; var result = new DataSourceResult() { Data = products, Total = _total }; return Json(result); }
/// <summary> /// 查询子权限列表 /// </summary> /// <param name="request"> /// 数据源请求信息对象 /// </param> /// <param name="permissionID"> /// 上级权限编号 /// </param> /// <returns> /// 执行方法结果 /// </returns> public ActionResult QueryPermissionByID([DataSourceRequest] DataSourceRequest request, int permissionID) { this.systemPermissionService = new SystemPermissionService(); int pageCount; int totalCount; var paging = new Paging("[System_Permission]", null, "ID", string.Format("ParentID = {0}", permissionID), request.Page, request.PageSize); var list = this.systemPermissionService.Query(paging, out pageCount, out totalCount); if (request.Page <= 0) { request.Page = 1; } if (list == null) { return this.View(); } var permissionModels = new List<PermissionModel>(); foreach (var systemPermission in list) { permissionModels.Add(DataTransfer.Transfer<PermissionModel>(systemPermission, typeof(System_Permission))); } var result = new DataSourceResult { Data = permissionModels, Total = totalCount }; return this.Json(result, JsonRequestBehavior.AllowGet); }
public ActionResult SearchResultsRead([DataSourceRequest] DataSourceRequest request) { EmployeeSearchAdditionalData employeeSearchAdditionalData = new EmployeeSearchAdditionalData(); TryUpdateModel(employeeSearchAdditionalData); int searchType = FindSearchType(employeeSearchAdditionalData); if (searchType == 0) { return null; } string domain = ConfigurationManager.AppSettings["LDAPDomain"]; string serviceUser = ConfigurationManager.AppSettings["ServiceUser"]; string servicePassword = ConfigurationManager.AppSettings["ServicePassword"]; LdapDirectoryIdentifier ldapDirectoryIdentifier = new LdapDirectoryIdentifier(domain); NetworkCredential myCredentials = new NetworkCredential(serviceUser, servicePassword); LdapConnection connection = new LdapConnection(ldapDirectoryIdentifier, myCredentials, AuthType.Basic); connection.SessionOptions.ProtocolVersion = 3; DirectoryContext context = new DirectoryContext(connection); var orders = context.Query<User>(); switch (searchType) { case 1: orders = orders.Where(u => (u.FirstName.Contains(employeeSearchAdditionalData.Keyword)) || (u.LastName.Contains(employeeSearchAdditionalData.Keyword))); break; case 2: orders = orders.Where(u => (u.CountryCode == employeeSearchAdditionalData.CountryCode1)); break; case 3: orders = orders.Where(u => ((u.FirstName.Contains(employeeSearchAdditionalData.Keyword)) || (u.LastName.Contains(employeeSearchAdditionalData.Keyword))) && (u.CountryCode == employeeSearchAdditionalData.CountryCode1)); break; case 4: if(!String.IsNullOrWhiteSpace(employeeSearchAdditionalData.FirstName)) { orders = orders.Where(u => (u.FirstName.Contains(employeeSearchAdditionalData.FirstName))); } if (!String.IsNullOrWhiteSpace(employeeSearchAdditionalData.LastName)) { orders = orders.Where(u => (u.LastName.Contains(employeeSearchAdditionalData.LastName))); } if (!String.IsNullOrWhiteSpace(employeeSearchAdditionalData.CountryCode2)) { orders = orders.Where(u => (u.CountryCode == employeeSearchAdditionalData.CountryCode2)); } if (!String.IsNullOrWhiteSpace(employeeSearchAdditionalData.Location)) { orders = orders.Where(u => (u.Location == employeeSearchAdditionalData.Location)); } if (!String.IsNullOrWhiteSpace(employeeSearchAdditionalData.PositionTitle)) { orders = orders.Where(u => (u.PositionTitle.Contains(employeeSearchAdditionalData.PositionTitle))); } if (!String.IsNullOrWhiteSpace(employeeSearchAdditionalData.FunctionalArea)) { orders = orders.Where(u => (u.FunctionalArea == employeeSearchAdditionalData.FunctionalArea)); } break; } orders = orders.Where(c => (c.Status == "Actif")); var total = orders.Count(); orders = orders.ApplyOrdersSorting(request.Groups, request.Sorts); var x = orders.ApplyOrdersPaging(request.Page, request.PageSize, total); var result = new DataSourceResult() { Data = x, Total = total }; return Json(result); }
/// <summary> /// The query product attribute value. /// </summary> /// <param name="productAttrID"> /// The product attr id. /// </param> /// <param name="request"> /// The request. /// </param> /// <returns> /// The <see cref="ActionResult"/>. /// </returns> public ActionResult QueryAttributeValue(string productAttrID, [DataSourceRequest] DataSourceRequest request) { DataSourceResult result; try { int totalCount; int pageCount; if (request.PageSize == 0) { request.PageSize = 10; } string condition = string.Format("AttributeID = {0}", productAttrID); var paging = new Paging("[Product_AttributeValue]", null, "ID", condition, request.Page, request.PageSize); var list = this.ProductAttributeValueService.Query(paging, out pageCount, out totalCount); result = new DataSourceResult(); if (list != null) { var modelList = new List<ProductAttributeValueModel>(); foreach (var product in list) { modelList.Add( DataTransfer.Transfer<ProductAttributeValueModel>(product, typeof(Product_AttributeValue))); } result.Data = modelList; result.Total = totalCount; return Json(result); } result.Data = null; result.Total = 0; } catch (Exception exception) { throw new Exception(exception.Message, exception); } return Json(result); }
/// <summary> /// The query product attribute. /// </summary> /// <param name="categoryID"> /// The category ID. /// </param> /// <param name="request"> /// The request. /// </param> /// <returns> /// The <see cref="ActionResult"/>. /// </returns> public ActionResult QueryAttribute(string categoryID, [DataSourceRequest] DataSourceRequest request) { if (request.PageSize == 0) { request.PageSize = 10; } DataSourceResult result; try { var condition = "1 = 1"; if (!string.IsNullOrEmpty(categoryID) && categoryID != "-1") { condition += string.Format(" and [ProductCategoryID] = {0} ", categoryID); } var paging = new Paging("[Product_Attribute]", null, "ID", condition, request.Page, request.PageSize); int pageCount; int totalCount; var list = this.ProductAttributeService.Query(paging, out pageCount, out totalCount); result = new DataSourceResult(); if (list != null) { var modelList = new List<ProductAttributeModel>(); foreach (var product in list) { modelList.Add( DataTransfer.Transfer<ProductAttributeModel>(product, typeof(Product_Attribute))); } result.Data = modelList; result.Total = totalCount; return Json(result); } result.Data = null; result.Total = 0; } catch (Exception exception) { throw new Exception(exception.Message, exception); } return Json(result); }
public ActionResult List([DataSourceRequest] DataSourceRequest request) { int _total = 0; SortDescriptor sortDescriptor = (request.Sorts != null && request.Sorts.Count > 0) ? request.Sorts.FirstOrDefault() : new SortDescriptor("Id", ListSortDirection.Ascending); sortDescriptor.Member = sortDescriptor.Member ?? "Title"; Func<IQueryable<Banner>, IOrderedQueryable<Banner>> order; var data = new List<Banner>(); switch (sortDescriptor.Member) { case "Title": if (sortDescriptor.SortDirection == ListSortDirection.Ascending) { order = x => x.OrderBy(y => y.Title); } else { order = x => x.OrderByDescending(y => y.Title); } break; case "DisplayOrder": if (sortDescriptor.SortDirection == ListSortDirection.Ascending) { order = x => x.OrderBy(y => y.DisplayOrder).ThenBy(z => z.Title); } else { order = x => x.OrderByDescending(y => y.DisplayOrder).ThenBy(z => z.Title); } break; default: if (sortDescriptor.SortDirection == ListSortDirection.Ascending) { order = x => x.OrderBy(y => y.Id); } else { order = x => x.OrderByDescending(y => y.Id); } break; } data = _bannerService.Select(null, order, null, request.Page, request.PageSize).ToList(); var banners = data.ToListModel(); _total = _bannerService.Select(null, order, null, null, null).Count(); ViewBag.Total = _total; var result = new DataSourceResult() { Data = banners, Total = _total }; return Json(result); }
/// <summary> /// LP活动列表. /// </summary> /// <param name="request"> /// The request. /// </param> /// <param name="filterYear"> /// The filter Year. /// </param> /// <param name="filterMonth"> /// The filter Month. /// </param> /// <returns> /// The <see cref="JsonResult"/>. /// </returns> public JsonResult QueryLandingPage( [DataSourceRequest] DataSourceRequest request, string filterYear, string filterMonth) { this.promoteLandingPageService = new PromoteLandingPageService(); if (request.Page <= 0) { request.Page = 1; } var stringBuilder = new StringBuilder(); if (!string.IsNullOrEmpty(filterYear)) { CheckCondition(stringBuilder); stringBuilder.Append("DATEDIFF(yyyy,CreateTime,'" + filterYear + "')=0"); } if (!string.IsNullOrEmpty(filterMonth)) { CheckCondition(stringBuilder); stringBuilder.Append("DATEDIFF(mm,CreateTime,'" + filterMonth + "-1')=0"); // (-1补全日期) } CheckCondition(stringBuilder); stringBuilder.Append("[IsDelete] = 0"); var condition = stringBuilder.ToString(); try { var paging = new Paging("[Promote_LandingPage]", null, "ID", condition, request.Page, request.PageSize, "CreateTime", 1); int pageCount; int totalCount; var list = this.promoteLandingPageService.QueryList(paging, out pageCount, out totalCount); if (list == null) { return this.Json(null); } var modelList = new List<PromoteLandingPageModel>(); foreach (var userLevelPrice in list) { var model = DataTransfer.Transfer<PromoteLandingPageModel>( userLevelPrice, typeof(Promote_LandingPage)); if (model.EndTime > DateTime.Now) { switch (model.Status) { case 1: model.StatusName = "正常"; break; case 2: model.StatusName = "暂停"; break; case 3: model.StatusName = "停止"; break; } } else { model.StatusName = "过期"; } modelList.Add(model); } var result = new DataSourceResult { Data = modelList, Total = totalCount }; return this.Json(result, JsonRequestBehavior.AllowGet); } catch (Exception exception) { throw new Exception(exception.Message, exception); } }
public JsonResult Index_GetProperties() { var userId = _sessionDetails.User.UserId; var response = _landlordService.GetPropertiesForLandlordList(userId); var result = new DataSourceResult() { Data = response.Items, Total = response.Count }; return Json(result); }
public ActionResult List([DataSourceRequest] DataSourceRequest request, string keyword = null) { int total = 0; var query = _solutionService.ODataQueryable().ToList(); SortDescriptor sortDescriptor = (request.Sorts != null && request.Sorts.Count > 0) ? request.Sorts.FirstOrDefault() : new SortDescriptor("DisplayOrder", ListSortDirection.Ascending); var asc = sortDescriptor.SortDirection.Equals(ListSortDirection.Ascending) ? true : false; Func<Solution, object> selector = x => x.Name; switch (sortDescriptor.Member) { case "DisplayOrder": selector = x => x.DisplayOrder; break; case "RootId": selector = x => x.RootId; break; } var data = query.Order(selector, asc).Skip((request.Page - 1) * request.PageSize).Take(request.PageSize).ToList(); var categories = data.ToListModel(); foreach (var category in categories) { category.TotalGallery = _galleryService.GetListGalleryDetailByObjectId(category.Id, (int)GalleryCategory.Category, (int)GalleryType.ImageAndVideo).Count; } total = query.Count(); ViewBag.Total = total; var result = new DataSourceResult() { Data = categories, Total = total }; return Json(result); }
/// <summary> /// 查询系统权限列表 /// </summary> /// <param name="request"> /// 数据源请求信息对象 /// </param> /// <returns> /// 执行方法结果 /// </returns> public ActionResult QueryMenu([DataSourceRequest] DataSourceRequest request) { this.systemMenuService = new SystemMenuService(); if (request.Page <= 0) { request.Page = 1; } int pageCount; int totalCount; var paging = new Paging("[System_Menu]", null, "ID", string.Format("ParentID = {0}", 0), request.Page, request.PageSize); var list = this.systemMenuService.Query(paging, out pageCount, out totalCount); if (list == null) { return this.View(); } var menuModels = new List<MenuModel>(); foreach (var systemMenu in list) { menuModels.Add(DataTransfer.Transfer<MenuModel>(systemMenu, typeof(System_Menu))); } var result = new DataSourceResult { Data = menuModels, Total = totalCount }; return this.Json(result, JsonRequestBehavior.AllowGet); }
public ActionResult MyWorkItem_Filter([DataSourceRequest] DataSourceRequest request) { GridFilter filter = request.GetFilter(); IDictionary<string, object> parameters = filter.Parameters; if (Request.QueryString["Entry"] == "WaitExecute") { parameters.SafeAdd("CurrentState", (short)WorkItemStatus.WaitExecute); } else if (Request.QueryString["Entry"] == "Compeleted") { parameters.SafeAdd("CurrentState", new Condition(string.Format(" CurrentState !={0}", (short)WorkItemStatus.WaitExecute))); } string sortCommand = filter.SortCommand ?? "order by CreateTime desc"; IPageOfList<WorkItem> data = workContext.IsAdmin ? repository.FindAll<WorkItem>(parameters, sortCommand, filter.PageInfo) : workflowEngine.GetMyWorkItems(workContext.User.ID, parameters, sortCommand, filter.PageInfo); var result = new DataSourceResult() { Data = data.Select(o => new WorkItemModel() { ID = o.ID, Creator = o.Creator, Name = o.Name, CreatorName = o.CreatorName, ProcessInstID = o.ProcessInstID, ProcessInstName = o.ProcessInstName, StartTime = o.StartTime, CurrentState = o.CurrentState.Cast<WorkItemStatus>(WorkItemStatus.WaitExecute).GetRemark() }), Total = (int)filter.PageInfo.ItemCount }; return Json(result); }
/// <summary> /// The query sub category. /// </summary> /// <param name="categoryID"> /// The category id. /// </param> /// <param name="request"> /// The request. /// </param> /// <returns> /// The <see cref="ActionResult"/>. /// </returns> public ActionResult QuerySubCategory(int categoryID, [DataSourceRequest] DataSourceRequest request) { if (request.PageSize == 0) { request.PageSize = 10; } DataSourceResult result; try { var codition = string.Format("ParentID = {0} and layer = 2 ", categoryID); int totalCount; int pageCount; var paging = new Paging("[Product_Category]", null, "ID", codition, request.Page, request.PageSize); var list = this.ProductCategoryService.Query(paging, out pageCount, out totalCount); if (list == null) { return this.Json(new DataSourceResult { Data = null, Total = 0 }); } var modelList = new List<ProductCategoryModel>(); foreach (var product in list) { modelList.Add(DataTransfer.Transfer<ProductCategoryModel>(product, typeof(Product_Category))); } result = new DataSourceResult { Data = modelList, Total = totalCount }; } catch (Exception exception) { throw new Exception(exception.Message, exception); } return this.Json(result); }
public ActionResult List([DataSourceRequest] DataSourceRequest request) { int _total = 0; SortDescriptor sortDescriptor = (request.Sorts != null && request.Sorts.Count > 0) ? request.Sorts.FirstOrDefault() : new SortDescriptor("Name", ListSortDirection.Descending); sortDescriptor.Member = sortDescriptor.Member ?? "Name"; Func<IQueryable<EmailTemplate>, IOrderedQueryable<EmailTemplate>> order; var data = new List<EmailTemplate>(); switch (sortDescriptor.Member) { default: if (sortDescriptor.SortDirection == ListSortDirection.Ascending) { order = x => x.OrderBy(y => y.Name); } else { order = x => x.OrderByDescending(y => y.Name); } break; } data = _emailTemplateService.Select(null, order, null, request.Page, request.PageSize).ToList(); _total = _emailTemplateService.Select(null, order, null, null, null).Count(); ViewBag.Total = _total; var result = new DataSourceResult() { Data = data, Total = _total }; return Json(result); }
public ActionResult Form_Filter([DataSourceRequest] DataSourceRequest request) { GridFilter filter = request.GetFilter(); IList<FormDataModel> data = repository.ExecuteDataTable<eForm>("select ID,Name,AppID,Creator,CreateTime from AB_eForm", filter.Parameters, filter.SortCommand ?? "order by CreateTime desc", filter.PageInfo).ToList<FormDataModel>(); var result = new DataSourceResult() { Data = data, Total = (int)filter.PageInfo.ItemCount }; return Json(result); }
public ActionResult StartProcess_Filter([DataSourceRequest] DataSourceRequest request) { GridFilter filter = request.GetFilter(); filter.Parameters.SafeAdd("CurrentState", (short)ProcessStatus.Release); IPageOfList<ProcessDef> data = repository.FindAll<ProcessDef>(filter.Parameters, filter.SortCommand ?? "order by CreateTime desc", filter.PageInfo); var result = new DataSourceResult() { Data = data, Total = (int)filter.PageInfo.ItemCount }; return Json(result); }
public ActionResult List([DataSourceRequest] DataSourceRequest request, string keyword = null) { int total = 0; var query = _userService.GetListUser(true, _userinfo.MaskPermission, _userinfo.UserName, keyword); //var data = query.ToList().OrderBy(x => x.UserName).Skip(request.Page - 1).Take(request.PageSize).AsEnumerable(); /* * Order sort User */ SortDescriptor sortDescriptor = (request.Sorts != null && request.Sorts.Count > 0) ? request.Sorts.FirstOrDefault() : new SortDescriptor("UserName", ListSortDirection.Descending); var asc = sortDescriptor.SortDirection.Equals(ListSortDirection.Ascending) ? true : false; Func<UserModel, object> selector = x => x.UserName; switch (sortDescriptor.Member) { case "FullName": selector = x => x.FullName; break; case "Email": selector = x => x.Email; break; } var data = query.Order(selector, asc).Skip(request.Page - 1).Take(request.PageSize).AsEnumerable(); total = query.Count(); ViewBag.total = total; var result = new DataSourceResult() { Data = data, Total = total }; return Json(result); }
public List<Auth_Role> GetPage(int page, int pageSize, string whereCondition) { List<SqlParameter> param = new List<SqlParameter>(); param.Add(new SqlParameter("@Page", page)); param.Add(new SqlParameter("@PageSize", pageSize)); param.Add(new SqlParameter("@WhereCondition", whereCondition)); DataTable dt = new SqlHelper().ExecuteQuery("p_Auth_Role_Select_By_Page", param); var lst = new List<Auth_Role>(); foreach (DataRow row in dt.Rows) { var item = new Auth_Role(); item.RoleID = !row.IsNull("RoleID") ? Convert.ToInt32(row["RoleID"]) : 0; item.RoleName = !row.IsNull("RoleName") ? row["RoleName"].ToString() : ""; item.IsActive = !row.IsNull("IsActive") ? Convert.ToBoolean(row["IsActive"]) : false; item.Note = !row.IsNull("Note") ? row["Note"].ToString() : ""; item.RowCreatedAt = !row.IsNull("RowCreatedAt") ? DateTime.Parse(row["RowCreatedAt"].ToString()) : DateTime.Parse("01/01/1900"); item.RowCreatedBy = !row.IsNull("RowCreatedBy") ? row["RowCreatedBy"].ToString() : ""; lst.Add(item); } DataSourceResult result = new DataSourceResult(); result.Data = lst; result.Total = dt.Rows.Count > 0 ? Convert.ToInt32(dt.Rows[0]["RowCount"]) : 0; return lst; }
/// <summary> /// The query product sold out. /// </summary> /// <param name="request"> /// The request. /// </param> /// <param name="productName"> /// The product name. /// </param> /// <param name="barcode"> /// The barcode. /// </param> /// <param name="parentCategoryID"> /// The parent category id. /// </param> /// <param name="productCategoryID"> /// The product category id. /// </param> /// <param name="parentBrandID"> /// The parent brand id. /// </param> /// <param name="productBrandID"> /// The product brand id. /// </param> /// <param name="minPrice"> /// The min price. /// </param> /// <param name="maxPrice"> /// The max price. /// </param> /// <returns> /// The <see cref="ActionResult"/>. /// </returns> public ActionResult QueryProductOnSale([DataSourceRequest] DataSourceRequest request, string productName, string barcode, string parentCategoryID, string productCategoryID, string parentBrandID, string productBrandID, string minPrice, string maxPrice) { int totalCount; var stringBuilder = new StringBuilder(); stringBuilder.Append("[Status] = 2"); if (!string.IsNullOrEmpty(productName)) { stringBuilder.Append(string.Format(" And [Name] like '%{0}%' ", productName)); } if (!string.IsNullOrEmpty(barcode)) { stringBuilder.Append(string.Format(" And [Barcode] like '%{0}%' ", barcode)); } if (!string.IsNullOrEmpty(parentCategoryID) && parentCategoryID != "-1") { stringBuilder.Append(string.Format(" And [ParentCategoryID] = {0} ", parentCategoryID)); } if (!string.IsNullOrEmpty(productCategoryID) && productCategoryID != "-1") { stringBuilder.Append(string.Format(" And [ProductCategoryID] = {0} ", productCategoryID)); } if (!string.IsNullOrEmpty(parentBrandID) && parentBrandID != "-1") { stringBuilder.Append(string.Format(" And [ParentBrandID] = {0} ", parentBrandID)); } if (!string.IsNullOrEmpty(productBrandID) && productBrandID != "-1") { stringBuilder.Append(string.Format(" And [ProductBrandID] = '{0}' ", productBrandID)); } if (!string.IsNullOrEmpty(minPrice)) { stringBuilder.Append(string.Format(" And [GoujiuPrice] >= '{0}' ", minPrice)); } if (!string.IsNullOrEmpty(maxPrice)) { stringBuilder.Append(string.Format(" And [GoujiuPrice] <= '{0}' ", maxPrice)); } var condition = stringBuilder.ToString(); var paging = new Paging("view_Product_Paging", null, "ID", condition, request.Page, request.PageSize, "CreateTime", 1); var productSearchResultModelList = new List<ProductSearchResultModel>(); try { int pageCount; var searchResult = this.ProductService.Query(paging, out pageCount, out totalCount); if (searchResult != null) { foreach (var productSearchResult in searchResult) { var item = DataTransfer.Transfer<ProductSearchResultModel>( productSearchResult, typeof(ProductSearchResult)); productSearchResultModelList.Add(item); } } } catch (Exception exception) { throw new Exception(exception.Message, exception); } var result = new DataSourceResult { Data = productSearchResultModelList, Total = totalCount }; return this.Json(result); }
public DataSourceResult GetPage(DataSourceRequest request, string whereCondition) { List<SqlParameter> param = new List<SqlParameter>(); param.Add(new SqlParameter("@Page", request.Page)); param.Add(new SqlParameter("@PageSize", request.PageSize)); param.Add(new SqlParameter("@WhereCondition", whereCondition)); param.Add(new SqlParameter("@Sort", CustomModel.GetSortStringFormRequest(request))); DataTable dt = new SqlHelper().ExecuteQuery("p_Auth_User_Select_By_Page", param); var lst = new List<Auth_User>(); foreach (DataRow row in dt.Rows) { var item = new Auth_User(); item.UserID = !row.IsNull("UserID") ? row["UserID"].ToString() : ""; item.FullName = !row.IsNull("FullName") ? row["FullName"].ToString() : ""; item.DisplayName = !row.IsNull("DisplayName") ? row["DisplayName"].ToString() : ""; item.Phone = !row.IsNull("Phone") ? row["Phone"].ToString() : ""; item.Email = !row.IsNull("Email") ? row["Email"].ToString() : ""; item.IsActive = !row.IsNull("IsActive") ? Convert.ToBoolean(row["IsActive"]) : false; item.Note = !row.IsNull("Note") ? row["Note"].ToString() : ""; item.RowCreatedAt = !row.IsNull("RowCreatedAt") ? DateTime.Parse(row["RowCreatedAt"].ToString()) : DateTime.Parse("01/01/1900"); item.RowCreatedBy = !row.IsNull("RowCreatedBy") ? row["RowCreatedBy"].ToString() : ""; item.Roles = !row.IsNull("Roles") ? row["Roles"].ToString() : ""; lst.Add(item); } request.Filters = null; DataSourceResult result = new DataSourceResult(); result.Data = lst; result.Total = dt.Rows.Count > 0 ? Convert.ToInt32(dt.Rows[0]["RowCount"]) : 0; return result; }