Пример #1
0
        public List<EDSurvey> GetAll(string scope)
        {
            List<EDSurvey> listObjects = new List<EDSurvey>();
            string query = ApiNamespace + "/surveys";

            if (!String.IsNullOrEmpty(scope))
                query = query + "?" + scope;

            var response = RequestGet(query);
            var json = response.Body;

            JArray jArray = null;
            JObject jObject = null;
            if (json != null && json.Length > 5)
                jObject = (JObject)JObject.Parse(json);

            if (jObject == null)
                return listObjects;

            jArray = (JArray)jObject["data"];

            foreach (JObject jo in jArray)
            {
                EDSurvey obj = new EDSurvey();

                if (obj.ParseJson((JObject)jo))
                    listObjects.Add(obj);
            }

            return listObjects;
        }
Пример #2
0
        // Use this to get the Survey given a world-survey id.
        // Easy to get to from a World object using the world-id attribute.
        public EDSurvey GetForId(int id)
        {
            if (id > 0)
            {
                var request = RequestGet($"{ApiNamespace}/surveys/{id}");
                if (request.StatusCode == HttpStatusCode.OK)
                {
                    var jo = JObject.Parse(request.Body);
                    var data = jo["data"];
                    EDSurvey obj = new EDSurvey();

                    return (obj.ParseJson((JObject)data)) ? obj : null;
                }
            }

            return null;
        }
Пример #3
0
        // Use this to get the Survey given a world-survey id.
        // Easy to get to from a World object using the world-id attribute.
        public EDSurvey GetForId(int id)
        {
            if (id > 0)
            {
                var request = RequestGet($"{ApiNamespace}/surveys/{id}");
                if (request.StatusCode == HttpStatusCode.OK)
                {
                    var      jo   = JObject.Parse(request.Body);
                    var      data = jo["data"];
                    EDSurvey obj  = new EDSurvey();

                    return((obj.ParseJson((JObject)data)) ? obj : null);
                }
            }

            return(null);
        }
Пример #4
0
        public List <EDSurvey> GetAll(string scope)
        {
            List <EDSurvey> listObjects = new List <EDSurvey>();
            string          query       = ApiNamespace + "/surveys";

            if (!String.IsNullOrEmpty(scope))
            {
                query = query + "?" + scope;
            }

            var response = RequestGet(query);
            var json     = response.Body;

            JArray  jArray  = null;
            JObject jObject = null;

            if (json != null && json.Length > 5)
            {
                jObject = (JObject)JObject.Parse(json);
            }

            if (jObject == null)
            {
                return(listObjects);
            }

            jArray = (JArray)jObject["data"];

            foreach (JObject jo in jArray)
            {
                EDSurvey obj = new EDSurvey();

                if (obj.ParseJson((JObject)jo))
                {
                    listObjects.Add(obj);
                }
            }

            return(listObjects);
        }