Payment GetDefaultTransaction(Person p) { Payment pay = p.Payments.FirstOrDefault(t => t.Name == "Default"); if (pay == null) { pay = new Payment("Default", p); } return(pay); }
private void btnAddItem_Click(object sender, EventArgs e) { Person selected = GetSelectedPerson(); Payment payment = GetDefaultTransaction(selected); Product product = new Product("New product", 100, payment, new List <Person>()); Product edited = ItemEditor.Edit(product, persons); if (edited != null) { Recalculate(); RefreshItems(); RefreshPersons(); RefreshButtons(); RefreshSummary(); SaveData(); SelectPerson(selected); SelectProduct(edited); } else { product.Transaction = null; } }