private GroupsListModel GetListModel(bool isMyGroupsPage, int page) { var take = page * ItemsPerPage; var currentMember = _memberService.GetCurrentMember(); var allGroups = isMyGroupsPage ? _groupService.GetMany(currentMember.GroupIds).ToList() : _groupService.GetAllNotHidden().ToList(); bool IsCurrentMemberInGroup(GroupModel g) => isMyGroupsPage || _groupMemberService.IsGroupMember(g.Id, currentMember.Id); var groups = allGroups .Select(g => MapGroupViewModel(g, IsCurrentMemberInGroup(g))) .OrderByDescending(g => g.Creator.Id == currentMember.Id) .ThenByDescending(s => s.IsMember) .ThenBy(g => g.Title); var model = new GroupsListModel { Groups = groups.Take(take), BlockScrolling = allGroups.Count <= take }; return(model); }
public virtual IActionResult List(DataSourceRequest command, GroupsListModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts)) { return(AccessDeniedKendoGridJson()); } var query = _gpRepository.TableNoTracking.Where(x => x.Deleted == false); query = query.OrderBy(x => x.GroupName); if (!string.IsNullOrEmpty(model.SearchGroupName)) { query = query.Where(x => x.GroupName.Contains(model.SearchGroupName)); } var groups = new PagedList <Groups>(query, command.Page - 1, command.PageSize); var gridModel = new DataSourceResult { Data = groups.Select(x => { var groupsModel = x.ToModel(); //categoryModel.Breadcrumb = x.GetFormattedBreadCrumb(_categoryService); return(groupsModel); }), Total = groups.TotalCount }; return(Json(gridModel)); }
public virtual IActionResult List() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts)) { return(AccessDeniedView()); } var model = new GroupsListModel(); model.AvailableStores.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); foreach (var s in _storeService.GetAllStores()) { model.AvailableStores.Add(new SelectListItem { Text = s.Name, Value = s.Id.ToString() }); } return(View("~/Plugins/Misc.ProductWizard/Views/Groups/List.cshtml", model)); }
public virtual ActionResult Index(bool isMyGroupsPage = false, int page = 1) { GroupsListModel model = GetListModel(isMyGroupsPage, page); return(PartialView(ListViewPath, model)); }