public TreeActionResult <MemberGroupTreeDto> GetTreeDataContainsMember([FromUri] MemberGroupFilter filter) { return(SafeGetTreeData(() => { var data = MemberGroupService.GetTreeDataContainsMember(filter); return data; })); }
public PagedActionResult <MemberGroup> Search([FromUri] MemberGroupFilter filter) { return(SafeGetPagedData <MemberGroup>((result) => { var totalCount = 0; var data = MemberGroupService.Search(filter, out totalCount); result.TotalCount = totalCount; result.Data = data; })); }
public IEnumerable <MemberGroupTreeDto> GetTreeDataContainsMember(MemberGroupFilter filter) { var result = new List <MemberGroupTreeDto>(); var memberQueryable = MemberRepo.GetQueryable(false) .Where(t => t.Card.Status != Domain.Enums.ECardStatus.Lost && t.Card.ExpiredDate != null ? t.Card.ExpiredDate >= DateTime.Now : true); if (filter != null && !string.IsNullOrEmpty(filter.CardNumberOrName)) { memberQueryable = memberQueryable.Where(t => t.CardNumber.Contains(filter.CardNumberOrName) || t.Name.Contains(filter.CardNumberOrName)); } var memberData = memberQueryable.Select(t => new { t.ID, t.MemberGroupID, t.Name, t.CardNumber }).ToList(); var memberGroups = Repository.GetQueryable(false).OrderBy(t => t.Index); memberGroups.ForEach(t => { var members = memberData.Where(m => m.MemberGroupID == t.ID).ToList(); var count = members.Count; result.Add(new MemberGroupTreeDto() { ID = t.ID, Text = t.Name + $"({count})", ParentId = null, expanded = true, Index = t.Index, Children = members.Select(c => new MemberGroupTreeDto { ID = c.ID, Text = string.IsNullOrEmpty(c.Name) ? c.CardNumber : c.Name + $"({c.CardNumber})", ParentId = t.ID, expanded = true, }).ToArray() }); }); return(result); }
public IEnumerable <MemberGroup> Search(MemberGroupFilter filter, out int totalCount) { var queryable = Repository.GetQueryable(false).Where(t => t.ID != _defaultGroupID); var result = new List <MemberGroup>(); if (filter != null) { if (!string.IsNullOrEmpty(filter.Name)) { queryable = queryable.Where(t => t.Name.Contains(filter.Name)); } if (!string.IsNullOrEmpty(filter.Code)) { queryable = queryable.Where(t => t.Code.Contains(filter.Code)); } } totalCount = queryable.Count(); if (filter != null && filter.Start.HasValue && filter.Limit.HasValue) { queryable = queryable.OrderBy(t => t.Index).Skip(filter.Start.Value).Take(filter.Limit.Value); } result = queryable.ToList(); return(result); }