public object Search([FromBody] GetContactsSearch query) { using (var dbCtx = new AddressBookEntities()) { var pb = (from s in dbCtx.phonebooks where s.Name.Contains(query.Seatch) select s).ToList(); var ret = pb.Select(x => { return(new ContactResult { Id = x.Id, Name = x.Name, Entries = x.entries.Select(y => new EntriesResult { Name = y.Name, Id = y.Id, PhonebookId = y.PhonebookId, PhoneNumber = y.PhoneNumber }).ToList() }); }); return(ret.ToList()); } }
public IResult <List <ContactUser> > GetContactList(GetContactsSearch search) { var result = new Result <List <ContactUser> >(); try { var list = _WeChatEngine.ContactList.Skip(search.Offset).Take(search.Limit).ToList(); result.Total = _WeChatEngine.ContactList.Count; result.Page = (int)Math.Ceiling(1.0 * result.Total / search.Limit); result.SetSuccess(); result.SetData(list); return(result); } catch (Exception ex) { return(base.SetException <List <ContactUser> >(ex)); } }
public JsonResult GetContactList(GetContactsSearch search) { var result = _WechatLogic.GetContactList(search); return(Json(result)); }