public void UpdateGrid(string newType) { var page = _grid.Pager; var newlist = newsServices.GetScfNewsByUser(CurrenUser) .Where(x => x.Type == (byte)NewType.News && (string.IsNullOrEmpty(newType) || x.Catelory.NameType == newType)); newlist = newlist.Where( x => string.IsNullOrEmpty(_grid.SearchCriteria.Header) || x.Header.Contains(_grid.SearchCriteria.Header)); var totalRows = (int)newlist.Count(); _grid.Pager.Init(totalRows); if (totalRows == 0) { _grid.Data = new List <NewsModel>(); return; } var list = newsServices.GetListPager(newlist, page.CurrentPage, page.PageSize); var listview = list.Select(x => NewsServices.ToModel(x)); var viewData = new List <NewsModel>(); foreach (var it in listview) { IEnumerable <ServerFile> files = freightServices.getServerFile(it.Id, new SSM.Models.NewsModel().GetType().ToString()); it.FilesList = files != null?files.ToList() : new List <ServerFile>(); viewData.Add(it); } _grid.Data = viewData; }
public void UpdateGridInfomation() { var orderField = new SSM.Services.SortField(_gridInfo.Pager.Sidx, _gridInfo.Pager.Sord == "asc"); filter.SortField = orderField; var page = _gridInfo.Pager; //bool checkEdit = CurrenUser.IsEditNew(null) || CurrenUser.AllowRegulationApproval; //var grpermission = CurrenUser.UserGroups.Select(x => x.GroupId).ToList(); var newlist = newsServices.GetScfNewsByUser(CurrenUser); newlist = newlist.Where(x => x.Type == (byte)NewType.Infomation && (string.IsNullOrEmpty(filter.Keyworks) || x.Header.Contains(filter.Keyworks)) && (filter.CategoryId == 0 || x.CateloryId == filter.CategoryId) && (x.IsApproved != filter.IsPending) && (filter.GroupId == 0 || x.GroupAccessPermissions.Any(g => g.GroupId == filter.GroupId)) ); newlist = newlist.OrderBy(orderField); var totalRows = (int)newlist.Count(); ViewBag.SearchingMode = filter ?? new NewSearchModel(); ViewBag.AllGroup = groupService.GetAll(x => x.IsActive); _gridInfo.Pager.Init(totalRows); if (totalRows == 0) { _gridInfo.Data = new List <NewsModel>(); return; } var list = newsServices.GetListPager(newlist, page.CurrentPage, page.PageSize); var listview = list.Select(x => NewsServices.ToModel(x)); var viewData = new List <NewsModel>(); foreach (var it in listview) { IEnumerable <ServerFile> files = freightServices.getServerFile(it.Id, new SSM.Models.NewsModel().GetType().ToString()); it.FilesList = files != null?files.ToList() : new List <ServerFile>(); viewData.Add(it); } _gridInfo.Data = viewData; }