public void SingleResource_Verify_CanCreate()
        {
            var request = new SDataSingleResourceRequest(_service)
            {
                ResourceKind = "employees"
            };

            var payload = new SDataPayload();

            payload.Values["Title"]            = "create 1";
            payload.Values["NationalIdNumber"] = "44444";
            payload.Values["LoginId"]          = "create 4";
            payload.Values["ContactId"]        = "9999";
            payload.Values["BirthDate"]        = SyndicationDateTimeUtility.ToRfc3339DateTime(new DateTime(1970, 8, 2));
            payload.Values["HireDate"]         = SyndicationDateTimeUtility.ToRfc3339DateTime(DateTime.Now);
            payload.Values["ModifiedDate"]     = SyndicationDateTimeUtility.ToRfc3339DateTime(DateTime.Now);
            payload.Values["MaritalStatus"]    = "Single";
            payload.Values["SalariedFlag"]     = XmlConvert.ToString(true);
            payload.Values["CurrentFlag"]      = XmlConvert.ToString(true);
            payload.Values["Gender"]           = "Male";
            payload.Values["RowGuid"]          = Guid.NewGuid().ToString();

            var entry = new AtomEntry
            {
                UpdatedOn   = DateTime.Now,
                PublishedOn = DateTime.Now
            };

            entry.SetSDataPayload(payload);
            request.Entry = entry;
            _mock.Setup(s => s.CreateEntry(request, request.Entry)).Returns(TestData.Entry);

            entry = request.Create();
            Expect(entry, Is.Not.Null);
        }
 private void btnSingleCreate_Click(object sender, EventArgs e)
 {
     try
     {
         var newEntry = _sdataSingleResourceRequest.Create();
         DisplayEntry(newEntry);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        public bool InsertRecord <T>(T dataItem)
        {
            bool returnData = false;

            // Create a SData serivce object connection.  Use the proper url and login info.
            ISDataService svc = new SDataService(GetFullSDataUrl(), _userId, _password);

            // Create the SData Payload of data to be sent
            SDataPayload myPayload = new SDataPayload();

            myPayload.Namespace    = string.Empty;
            myPayload.ResourceName = typeof(T).Name;
            myPayload.Uri          = new Uri(svc.Url);

            // Add to an ATOM feed entry b/c that's what SData uses
            AtomEntry myEntry = new AtomEntry();

            myEntry.SetSDataPayload(myPayload);

            // loop through the properties to find matching data from our query
            foreach (PropertyInfo property in dataItem.GetType().GetProperties())
            {
                // If the property value is null, don't add it
                if (property.GetValue(dataItem) == null)
                {
                    continue;
                }

                myPayload.Values.Add(property.Name, property.GetValue(dataItem));
            }

            // prepare the create request
            SDataSingleResourceRequest sendRequest = new SDataSingleResourceRequest(svc, myEntry);

            sendRequest.ResourceKind     = typeof(T).Name;
            sendRequest.ResourceSelector = "";

            try
            {
                AtomEntry response = sendRequest.Create();
                returnData = true;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                returnData = false;
            }

            return(returnData);
        }