private void btnSingleUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         var newEntry = _sdataSingleResourceRequest.Update();
         DisplayEntry(newEntry);
         StatusLabel.Text = Resources.statusUpdateComplete;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        public void SingleResource_Verify_CanProcess_SDataBatchRequest()
        {
            var request1 = new SDataSingleResourceRequest(_service)
            {
                ResourceKind     = "employees",
                ResourceSelector = "1"
            };
            var request2 = new SDataSingleResourceRequest(_service)
            {
                ResourceKind     = "employees",
                ResourceSelector = "2"
            };
            var request3 = new SDataSingleResourceRequest(_service)
            {
                ResourceKind     = "employees",
                ResourceSelector = "3"
            };

            _mock.Setup(s => s.ReadEntry(request1)).Returns(TestData.Entry);
            _mock.Setup(s => s.ReadEntry(request2)).Returns(TestData.Entry);
            _mock.Setup(s => s.ReadEntry(request3)).Returns(TestData.Entry);

            request2.Entry = request2.Read();
            request3.Entry = request3.Read();

            _mock.Setup(s => s.UpdateEntry(request2, request2.Entry)).Returns(TestData.Entry);
            _mock.Setup(s => s.DeleteEntry(request3, request3.Entry)).Returns(true);

            var payload2 = request2.Entry.GetSDataPayload();

            payload2.Values["MaritalStatus"] = "Married";

            AtomFeed batchfeed;

            using (var batch = new SDataBatchRequest(_service))
            {
                batch.ResourceKind = "employees";
                request1.Read();
                request2.Update();
                request3.Delete();

                _mock.Setup(s => s.CreateFeed(batch, It.IsAny <AtomFeed>())).Returns(TestData.Feed);
                batchfeed = batch.Commit();
            }

            Expect(batchfeed, Is.Not.Null);
        }
        public bool UpdateTechnicianRecord(JT_Technician 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(JT_Technician).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);

            // update only specific properties
            myPayload.Values.Add("CurrentStartTime", dataItem.CurrentStartTime);
            myPayload.Values.Add("CurrentStartDate", dataItem.CurrentStartDate.ToString("yyyy-MM-dd"));
            myPayload.Values.Add("CurrentSalesOrderNo", dataItem.CurrentSalesOrderNo);
            myPayload.Values.Add("CurrentWTNumber", dataItem.CurrentWTNumber);
            myPayload.Values.Add("CurrentWTStep", dataItem.CurrentWTStep);
            myPayload.Values.Add("CurrentStatus", dataItem.CurrentStatus);

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

            sendRequest.ResourceKind     = typeof(JT_Technician).Name;
            sendRequest.ResourceSelector = dataItem.TechnicianDeptNo + ";" + dataItem.TechnicianNo;

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

            return(returnData);
        }
        public void SingleResource_Verify_CanUpdate()
        {
            var request = new SDataSingleResourceRequest(_service)
            {
                ResourceKind     = "employees",
                ResourceSelector = "1"
            };

            _mock.Setup(s => s.ReadEntry(request)).Returns(TestData.Entry);

            var entry   = request.Read();
            var payload = entry.GetSDataPayload();

            payload.Values["Title"] = "test update";
            request.Entry           = entry;
            _mock.Setup(s => s.UpdateEntry(request, request.Entry)).Returns(TestData.Entry);

            entry = request.Update();
            Expect(entry, Is.Not.Null);
        }