public async void GetAllCompanies() { DataCompany[] allCompanies = await CompanyHelper.GetAllCompanies(); for (int i = 0; i < allCompanies.Length; i++) { DataCompany c = allCompanies[i]; Companies.Add(c); } ListboxCompanies.ItemsSource = Companies; }
public static DataCompany GetCompany(string abn) { string dir = ABNHelper.GetDirectory(abn); string filePath = dir + "/CompanyInfo.info"; if (File.Exists(dir + "/CompanyInfo.info")) { DataCompany company = JsonConvert.DeserializeObject <DataCompany>(File.ReadAllText(filePath)); return(company); } return(null); }
internal static void SaveChanges(DataCompany dataCompany) { string dir = ABNHelper.GetDirectory(dataCompany.ABN); string filePath = dir + "/CompanyInfo.info"; DocumentReference d = App.db.Collection("Trades").Document(dataCompany.CompanyName); d.SetAsync(dataCompany); string s = JsonConvert.SerializeObject(dataCompany); StreamWriter writer = new StreamWriter(filePath); writer.Write(s); writer.Flush(); writer.Close(); }
private void RemoveContactButton_Click(object sender, RoutedEventArgs e) { var ds = ListviewContacts.SelectedItems; if (ds == null) { return; } string message = ds.Count == 1 ? "Are you sure you wish to delete this item?" : $"Are you sure you wish to delete {ds.Count} items?"; var response = MessageBox.Show(message, "Are you sure?", MessageBoxButton.YesNo); if (response == MessageBoxResult.Yes) { DataCompany company = ((DataCompany)DataContext); company.Contacts.Remove((DataContact)ListviewContacts.SelectedItem); } }