static void AddData() { Customer customer = new Customer { FirstName = "Василий", LastName = "Печкин", }; Seller seller = new Seller { FirstName = "Владислав", LastName = "Соколов", }; Purchase purchase = new Purchase { CustomerId = customer.Id, SellerId = seller.Id, Sum = 100 }; CustomerRepository customerRepository = new CustomerRepository(); customerRepository.Add(customer); SellerRepository sellerRepository = new SellerRepository(); sellerRepository.Add(seller); PurchaseRepository purchaseRepository = new PurchaseRepository(); purchaseRepository.Add(purchase); }
private void buttonShowSellers_Click(object sender, EventArgs e) { SellerRepository sellerRepository = new SellerRepository(); ICollection <Seller> sellers = sellerRepository.GetAll(); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("Данные из таблицы Продавцов: \n"); foreach (var seller in sellers) { stringBuilder.Append($"{seller.Id} {seller.FirstName} {seller.LastName}\n"); } MessageBox.Show(stringBuilder.ToString()); }