Example #1
0
        private async void UpdateRestServerContractSalesItem(ContractSalesItem contractSalesItem)
        {
            // Upload the item to the server via REST:
            string data      = contractSalesItem.DataToString();
            var    webClient = new WebClient();

            webClient.Headers[HttpRequestHeader.ContentType] = "application/json";
            webClient.Encoding = Encoding.UTF8;
            string response = null;

            try
            {
                response = await webClient.UploadStringTaskAsync(BaseUrl + "/api/ContractSalesItem/" + contractSalesItem.Id.ToString(), "PUT", data);
            }
            catch (Exception e)
            {
                MessageBox.Show("Failed to upload item via REST. Exception message: " + e.Message);
            }

            // Send message via SignalR to update the other clients:
            if (response != null)
            {
                MakeCallToUpdateOtherClients();
            }
        }
Example #2
0
        private async void AddToRestServerContractSalesItem(ContractSalesItem contractSalesItem)
        {
            string data = contractSalesItem.DataToString();

            // Upload the item to the server via REST:
            var webClient = new WebClient();

            webClient.Headers[HttpRequestHeader.ContentType] = "application/json";
            webClient.Encoding = Encoding.UTF8;
            try
            {
                await webClient.UploadStringTaskAsync(BaseUrl + "/api/ContractSalesItem/", "POST", data);
            }
            catch (Exception e)
            {
                MessageBox.Show("Failed to upload item via REST. Exception message: " + e.Message);

                return;
            }

            // Send message via SignalR to update the other clients:
            MakeCallToUpdateOtherClients();
        }