public ActionResult FetchPeople(string data)
        {
            // Authenticate first
            var result = AuthenticateUser();

            if (!result.IsValid)
            {
                return(AuthorizationError(result));
            }

            BaseMessage      dataIn = BaseMessage.createFromString(data);
            MobilePostSearch mps    = JsonConvert.DeserializeObject <MobilePostSearch>(dataIn.data);

            BaseMessage br = new BaseMessage();

            var m = new SearchModel(mps.name, mps.comm, mps.addr);

            br.error = 0;
            br.count = m.Count;

            switch (dataIn.device)
            {
            case BaseMessage.API_DEVICE_ANDROID:
            {
                Dictionary <int, MobilePerson> mpl = new Dictionary <int, MobilePerson>();

                MobilePerson mp;

                foreach (var item in m.ApplySearch().OrderBy(p => p.Name2).Take(20))
                {
                    mp = new MobilePerson().populate(item);
                    mpl.Add(mp.id, mp);
                }

                br.data = JsonConvert.SerializeObject(mpl);
                break;
            }

            case BaseMessage.API_DEVICE_IOS:
            {
                List <MobilePerson> mp = new List <MobilePerson>();

                foreach (var item in m.ApplySearch().OrderBy(p => p.Name2).Take(20))
                {
                    mp.Add(new MobilePerson().populate(item));
                }

                br.data = JsonConvert.SerializeObject(mp);
                break;
            }
            }
            return(br);
        }
示例#2
0
        public ActionResult Search(string name, string comm, string addr)
        {
            BaseReturn          br = new BaseReturn();
            List <MobilePerson> mp = new List <MobilePerson>();

            var m = new SearchModel(name, comm, addr);

            br.type  = 1;
            br.count = m.Count;

            foreach (var item in m.ApplySearch().OrderBy(p => p.Name2).Take(20))
            {
                mp.Add(new MobilePerson().populate(item));
            }

            br.data = JSONHelper.JsonSerializer <List <MobilePerson> >(mp);
            return(br);
        }
示例#3
0
        public ActionResult FetchPeople(string data)
        {
            // Authenticate first
            var result = AuthenticateUser();
            if (!result.IsValid) return AuthorizationError(result);

            BaseMessage dataIn = BaseMessage.createFromString(data);
            MobilePostSearch mps = JsonConvert.DeserializeObject<MobilePostSearch>(dataIn.data);

            BaseMessage br = new BaseMessage();

            var m = new SearchModel(mps.name, mps.comm, mps.addr);

            br.setNoError();
            br.count = m.Count;

            switch (dataIn.device)
            {
                case BaseMessage.API_DEVICE_ANDROID:
                    {
                        Dictionary<int, MobilePerson> mpl = new Dictionary<int, MobilePerson>();

                        MobilePerson mp;

                        foreach (var item in m.ApplySearch().OrderBy(p => p.Name2).Take(100))
                        {
                            mp = new MobilePerson().populate(item);
                            mpl.Add(mp.id, mp);
                        }

                    br.data = SerializeJSON(mpl, dataIn.version);
                        break;
                    }

                case BaseMessage.API_DEVICE_IOS:
                    {
                        List<MobilePerson> mp = new List<MobilePerson>();

                        foreach (var item in m.ApplySearch().OrderBy(p => p.Name2).Take(100))
                        {
                            mp.Add(new MobilePerson().populate(item));
                        }

                    br.data = SerializeJSON(mp, dataIn.version);
                        break;
                    }
            }

            return br;
        }