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(); } }
/* // Commented out because the data is now downloaded from the server. * List<ContractSalesItem> GetContractSalesItems() * { * List<ContractSalesItem> contractSalesitems = new List<ContractSalesItem>(); * // company name, primary contact, zdTicket, status, order comment * contractSalesitems.Add(new ContractSalesItem("MikeRoweSoft", "Mike Rowe", 1, PROPOSAL, 5, "Would like to be allowed to use this name for their company but aren't")); * contractSalesitems.Add(new ContractSalesItem("Pidiboup", "This one", 12, CLOSED_WON, 3, "Pretty cool company name")); * contractSalesitems.Add(new ContractSalesItem("AyoYayA", "A serious one", 2, PROPOSAL, 1)); * contractSalesitems.Add(new ContractSalesItem("Apple", "One that does more, costs less", 5, LEAD, 2, "Considers costing more while doing less, thus becoming a luxury product")); * contractSalesitems.Add(new ContractSalesItem("Lorem Ipsum TM", "A plain ol' contact", 3, PROPOSAL, 6, "Dolor sit amet etc.")); * contractSalesitems.Add(new ContractSalesItem("CorpyCorp", "The best one", 1239, LEAD, 9, "Do not forget to be \"corporate\"")); * contractSalesitems.Add(new ContractSalesItem("LimitedLTD", "Confidential", 7, PROPOSAL, 8, "You wish you knew")); * contractSalesitems.Add(new ContractSalesItem("SCP Foundation", "REDACTED", 8, PROPOSAL, 7, "You do not want to know")); * contractSalesitems.Add(new ContractSalesItem("Charmander", "Spicy", 4, PROPOSAL, 4, "Always on fire")); * contractSalesitems.Add(new ContractSalesItem("Koji Kondo", "Musical", 6, LEAD, 10, "Gives an identity to games")); * contractSalesitems.Add(new ContractSalesItem("Some movie", "Some actor", 10, CLOSED_WON, 11, "Some plot twist")); * contractSalesitems.Add(new ContractSalesItem("Anarchists", "None", 11, LEAD, 12, "They don't know what they are doing so how would we?")); * contractSalesitems.Add(new ContractSalesItem("To be continued", "A future one", 13, LEAD, 13, "The anticipation is killing me!!!")); * contractSalesitems.Add(new ContractSalesItem("I don't know", "Some guy", 133, UNCLASSIFIED, 19, "This should only appear with the unclassified column")); * return contractSalesitems; * } */ private void ButtonCreateItem_Click(object sender, RoutedEventArgs e) { //todo: display the ChildWindow to create a new ContractSalesItem. ContractSalesItem newContractSalesItem = new ContractSalesItem(); var childWindow = new CreateEditItemChildWindow(); childWindow.DataContext = newContractSalesItem; childWindow.Closed += ChildWindowCreateItem_Closed; childWindow.Show(); }
private void ChildWindowCreateItem_Closed(object sender, EventArgs e) { ChildWindow childWindow = ((ChildWindow)sender); if (childWindow.DialogResult == true) { ContractSalesItem item = childWindow.DataContext as ContractSalesItem; if (item != null) { _contractSalesitems.Add(item); MyKanBanControl.ItemsSource = null; MyKanBanControl.ItemsSource = _contractSalesitems; AddToRestServerContractSalesItem(item); } } }
private async void DeleteFromRestServerContractSalesItem(ContractSalesItem contractSalesItem) { // Update the server via REST: var webClient = new WebClient(); try { string response = await webClient.UploadStringTaskAsync(BaseUrl + "/api/ContractSalesItem/" + contractSalesItem.Id.ToString(), "DELETE", ""); } 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(); }
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(); }
private void ChildWindowEditItem_Closed(object sender, EventArgs e) { ChildWindow childWindow = ((ChildWindow)sender); if (childWindow.DialogResult == true) { ContractSalesItem item = childWindow.DataContext as ContractSalesItem; if (item != null && item.CloneOf != null) //CloneOf should never be null but we never know. { //we apply the changes that were applied to the clone to the original: ContractSalesItem original = item.CloneOf; original.CompanyName = item.CompanyName; original.PrimaryContact = item.PrimaryContact; original.ZenDeskTicketId = item.ZenDeskTicketId; original.StatusInSalesCycle = item.StatusInSalesCycle; original.Order = item.Order; original.Comments = item.Comments; UpdateRestServerContractSalesItem(original); MyKanBanControl.Refresh(); } } }