Beispiel #1
0
        public async Task <BaseResponse> GetGroupsAsync(GroupListRequest req)
        {
            GroupListViewModel rm = new GroupListViewModel();
            //根据要查找的字段进行查找
            Expression <Func <GroupModel, bool> > predicate;

            if (string.IsNullOrWhiteSpace(req.Field) || string.IsNullOrWhiteSpace(req.FieldValue))
            {
                predicate = a => true;
            }
            else
            {
                predicate = LinqHelper <GroupModel> .Contains(req.Field, req.FieldValue);
            }
            var groups = _group.Find(predicate);

            if (req.OrderType.ToUpper() == "ASC")
            {
                groups = groups.OrderBy(LinqHelper <GroupModel> .Order <string>(req.OrderField /*a => a.GetType().GetProperty(req.OrderField)*/));
            }
            else
            {
                groups = groups.OrderByDescending(LinqHelper <GroupModel> .Order <string>(req.OrderField));
            }
            var gml = await groups.ToListAsync();

            foreach (var item in gml)
            {
                //rm.Data.Add(new GroupData() { Id = item.Id, Code = item.Code, Description = item.Description, Logo = item.Logo, Name = item.Name });
            }
            rm.Success = true;
            rm.Message = "获取数据成功";
            return(rm);
        }
 public void GetGroupList()
 {
     GroupListRequest request = new GroupListRequest();
     request.uid = this.sessionService.Uid;
     this.connection.Send(PacketType.ENT_GROUP_LIST, request);
 }