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 cmdSave_Click(object sender, EventArgs e)
        {
            try
            {
                ISDataService service;
                service = SDataDataService.mydataService();

                string ownerId = UserNameToOwnerId.GetId(service.UserName);

                var entry = new AtomEntry();
                var payload = new SDataPayload
                {
                    ResourceName = "Ticket",
                    Namespace = "http://schemas.sage.com/dynamic/2007",
                    Values = {
                    {"Account", (SDataPayload)contactPayload.Values["Account"]},
                    {"Contact", contactPayload},//,
                                {"AssignedTo", new SDataPayload{ Key = ownerId, ResourceName="Owner"}},
                                //{"Issue",txtSubject.Text},
                                {"TicketProblem", new SDataPayload{
                                    ResourceName="TicketProblem",
                                    Values = {
                                        {"Notes",txtSubject.Text}
                                    }
                                }
                                }
                    }
                };

                entry.SetSDataPayload(payload);
                var request = new SDataSingleResourceRequest(service, entry) { ResourceKind = "Tickets" };
                AtomEntry result = request.Create();

                this.Close();

            }
            catch (SDataClientException ex)
            {
                //MessageBox.Show(ex.Message);
                //Getting object reference error and have no idea why
                //Everything is created just fine and is working though still get error
                this.Close();
            }
        }
        private void cmdSave_Click(object sender, EventArgs e)
        {
            try
            {
                ISDataService service;
                service = SDataDataService.mydataService();

                string ownerId = UserNameToOwnerId.GetId(service.UserName);
                string userId = UserNameToId.GetId(service.UserName);

                var entry = new AtomEntry();
                var payload = new SDataPayload
                {
                    ResourceName = "Opportunity",
                    Namespace = "http://schemas.sage.com/dynamic/2007",
                    Values = {
                                {"Description", txtDescription.Text},
                                {"Account", (SDataPayload)contactPayload.Values["Account"]},
                                {"Owner", new SDataPayload{ Key = ownerId, ResourceName="Owner"}},
                                {"AccountManager", new SDataPayload{ Key = userId, ResourceName="AccountManager"}},
                                {"Contacts",
                                    new SDataPayloadCollection {
                                        new SDataPayload {
                                            ResourceName = "OpportunityContact",
                                            Values = {{"Contact",new SDataPayload{ Key = contactPayload.Key}},
                                                      {"IsPrimary","true"}}
                                        }
                                    }
                                }
                             }
                };

                entry.SetSDataPayload(payload);
                var request = new SDataSingleResourceRequest(service, entry) { ResourceKind = "Opportunities" };
                AtomEntry result = request.Create();

                this.Close();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void cmdSave_Click(object sender, EventArgs e)
        {
            try
            {
                ISDataService service;
                service = SDataDataService.mydataService();

                string contactId = contactPayload.Key; ;
                string contactName = contactPayload.Values["FirstName"].ToString().Trim() + " " + contactPayload.Values["LastName"].ToString().Trim();

                SDataPayload accountPayload = (SDataPayload)contactPayload.Values["Account"];
                string accountId = accountPayload.Key;
                string accountName = contactPayload.Values["AccountName"].ToString().Trim();

                var entry = new AtomEntry();
                var payload = new SDataPayload
                {
                    ResourceName = "Activity",
                    Namespace = "http://schemas.sage.com/dynamic/2007",
                    Values = {
                    {"AccountId", accountId},
                    //{"AccountName", accountName},
                    {"ContactId", contactId},
                    {"Description", txtRegarding.Text}
                    }
                };

                entry.SetSDataPayload(payload);
                var request = new SDataSingleResourceRequest(service, entry) { ResourceKind = "Activities" };
                AtomEntry result = request.Create();

                if (result != null)
                {
                    //MessageBox.Show("Acctivity created");
                }

                this.Close();

            }
            catch (SDataClientException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    public static string Create(string oppoId, string contactId)
    {
        try
            {
                ISDataService service;
                service = SDataDataService.mydataService();

                var entry = new AtomEntry();
                var payload = new SDataPayload
                {
                    ResourceName = "OpportunityContact",
                    Namespace = "http://schemas.sage.com/dynamic/2007",
                    Values = {
                                {"Contact", new SDataPayload{ Key = contactId, ResourceName="Contact"}},
                                {"Opportunity", new SDataPayload{ Key = oppoId, ResourceName="Opportunity"}}
                             }
                };

                entry.SetSDataPayload(payload);
                var request = new SDataSingleResourceRequest(service, entry) { ResourceKind = "OpportunityContacts" };
                AtomEntry result = request.Create();

                if (result != null)
                {
                    return result.Id.ToString();
                }
                else
                {
                    return null;
                }
            }
            catch (Exception ex)
            {
                return null;
            }
    }
        private void cmdSave_Click(object sender, EventArgs e)
        {
            try
            {
                ISDataService service;
                service = SDataDataService.mydataService();

                var entry = new AtomEntry();
                var payload = new SDataPayload
                {
                    ResourceName = "Account",
                    Namespace = "http://schemas.sage.com/dynamic/2007",
                    Values = {
                        {"AccountName", txtAccount.Text},
                        {"Contacts", new SDataPayloadCollection {
                                new SDataPayload {
                                    ResourceName = "Contact",
                                    Values = {
                                        {"AccountName",  txtAccount.Text},
                                        {"LastName", txtLName.Text},
                                        {"FirstName", txtFName.Text},
                                        {"Email",txtEmail.Text}
                                    }
                                }
                            }
                        }
                    }
                };

                entry.SetSDataPayload(payload);
                var request = new SDataSingleResourceRequest(service, entry) { ResourceKind = "accounts" };
                AtomEntry result = request.Create();

                if(result != null)
                {
                    this.DialogResult = System.Windows.Forms.DialogResult.Yes;
                }

                this.Close();

            }
            catch (SDataClientException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void cmdSave_Click(object sender, EventArgs e)
        {
            try
            {
                ISDataService service;
                service = SDataDataService.mydataService();

                var entry = new AtomEntry();
                var payload = new SDataPayload
                {
                    ResourceName = "Lead",
                    Namespace = "http://schemas.sage.com/dynamic/2007",
                    Values = {
                        {"Company", txtCompany.Text.Trim()},
                        {"FirstName",txtFName.Text.Trim()},
                        {"LastName",txtLName.Text.Trim()},
                        {"Email",txtEmail.Text.Trim()},
                        {"Address",
                                new SDataPayload {
                                    ResourceName = "LeadAddress",
                                    Values = {
                                        {"Address1",  txtAddress.Text.Trim()},
                                        {"City", txtCity.Text.Trim()},
                                        {"State", txtState.Text.Trim()},
                                        {"PostalCode",txtPostalCode.Text.Trim()}
                                    }
                                }
                        }
                    }
                };

                entry.SetSDataPayload(payload);
                var request = new SDataSingleResourceRequest(service, entry) { ResourceKind = "leads" };
                AtomEntry result = request.Create();

                if (result != null)
                {
                    this.DialogResult = System.Windows.Forms.DialogResult.Yes;
                }

                this.Close();

            }
            catch (SDataClientException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }