public void DeleteItem(int Id)
 {
     var contextInfo = GetContextInfo();
     var url = new TestListBuilder().FromList("Test List").WithItem(Id).Build();
     HttpWebRequest request =
         (HttpWebRequest)HttpWebRequest.Create(url);
     request.Method = "POST";
     request.Credentials = credentials;
     request.ContentLength = 0;
     request.Headers.Add("IF-MATCH", "*");
     request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");
     request.Headers.Add("X-RequestDigest", contextInfo.d.GetContextWebInformation.FormDigestValue);
     request.Headers.Add("X-HTTP-Method", "DELETE");
     HttpWebResponse itemResponse = (HttpWebResponse)request.GetResponse();
 }
        public void AddItem(TestListItemEntity entity)
        {
            var contextInfo = GetContextInfo();
            string itemPostBody = (new TestListItemBuilder()).WithType(entityType).WithItem(entity).Build();
            Byte[] itemPostData = System.Text.Encoding.ASCII.GetBytes(itemPostBody);

            var url = new TestListBuilder().FromList("Test List").WithAllItems().Build();
            HttpWebRequest request =
                (HttpWebRequest)HttpWebRequest.Create(url);
            request.Method = "POST";
            request.ContentLength = itemPostBody.Length;
            request.ContentType = "application/json;odata=verbose";
            request.Credentials = credentials;
            request.Accept = "application/json;odata=verbose";
            request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");
            request.Headers.Add("X-RequestDigest", contextInfo.d.GetContextWebInformation.FormDigestValue);
            Stream itemRequestStream = request.GetRequestStream();

            itemRequestStream.Write(itemPostData, 0, itemPostData.Length);
            itemRequestStream.Close();

            HttpWebResponse itemResponse = (HttpWebResponse)request.GetResponse();
        }
        public IList<TestListItemEntity> GetAllItems()
        {
            var url = new TestListBuilder().FromList("Test List").WithAllItems().Build();
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
            request.Method = "GET";
            request.Accept = "application/json;odata=verbose";
            request.ContentType = "application/json;odata=verbose";
            request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");
            request.Credentials = credentials;
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            StreamReader stream = new StreamReader(response.GetResponseStream());
            var testList = (TestList)JsonConvert.DeserializeObject<TestList>(stream.ReadLine());
            var result = new List<TestListItemEntity>();
            foreach(var item in testList.d.results)
            {
                var temp = new TestListItemEntity()
                {
                    Id = item.Id,
                    Title = item.Title,
                    Experience = item.Experience

                };
                result.Add(temp);
            }
            return result;
        }
 public TestListItemEntity GetItem(int id)
 {
     var url = new TestListBuilder().FromList("Test List").WithItem(id).Build();
     HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
     request.Method = "GET";
     request.Accept = "application/json;odata=verbose";
     request.ContentType = "application/json;odata=verbose";
     request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");
     request.Credentials = credentials;
     HttpWebResponse response = (HttpWebResponse)request.GetResponse();
     StreamReader stream = new StreamReader(response.GetResponseStream());
     var item = ((TestItem)JsonConvert.DeserializeObject<TestItem>(stream.ReadLine())).d;
     return new TestListItemEntity()
     {
         Id = item.Id,
         Title = item.Title,
         Experience = item.Experience
     };
 }