Пример #1
0
        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);
        }
Пример #2
0
        private void buttonShowPurchases_Click(object sender, EventArgs e)
        {
            PurchaseRepository     purchaseRepository = new PurchaseRepository();
            ICollection <Purchase> purchases          = purchaseRepository.GetAll();

            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("Данные из таблицы Покупок: \n");

            foreach (var purchase in purchases)
            {
                stringBuilder.Append($"{purchase.Id} {purchase.SellerId} {purchase.CustomerId} {purchase.Sum} {purchase.CreationDate}\n");
            }

            MessageBox.Show(stringBuilder.ToString());
        }