public Travel(Company from, Company to, DateTime date, float distance) { this._From = from; this._To = to; this._Date = date; this._Distance = distance; }
private void NewCompany_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrEmpty(this.NewCompanyName.Text) && !string.IsNullOrWhiteSpace(this.NewCompanyName.Text) && !string.IsNullOrEmpty(this.NewCompanyAddress.Text) && !string.IsNullOrWhiteSpace(this.NewCompanyAddress.Text)) { if (this._Companies.Any(c => c.Name.ToLower() == this.NewCompanyName.Text.ToLower())) { MessageBox.Show("This company already exists.", "Impossible", MessageBoxButton.OK, MessageBoxImage.Warning); } else { Company company = new Company(this.NewCompanyName.Text, this.NewCompanyAddress.Text); this._Companies.Add(company); this.From.Items.Add(company.Name); this.To.Items.Add(company.Name); this.NewCompanyName.Text = string.Empty; this.NewCompanyAddress.Text = string.Empty; this.SaveListToFile(this._PathToCompagniesFile, this._Companies); } } }