Exemple #1
0
        private void Edit_Click(object sender, RoutedEventArgs e)
        {
            ApartementDTO apart = (ApartementDTO)DataGridApartment.SelectedItem;

            Apartment ap = context.Apartments.FirstOrDefault(t => t.Id == apart.Id);



            foreach (var p in context.Apartments)
            {
                if (p.Id == apart.Id)
                {
                    var temp = apartments.First(t => t.Id == apart.Id);
                    temp.Number   = NumberTextBox.Text;
                    ap.Number     = NumberTextBox.Text;
                    ap.Price      = decimal.Parse(PriceTextBox.Text);
                    ap.Square     = double.Parse(SquareTextBox.Text);
                    ap.CountRooms = int.Parse(CountRoomsTextBox.Text);


                    break;
                }
            }
            context.SaveChanges();
        }
Exemple #2
0
        private void Buy_Click(object sender, RoutedEventArgs e)
        {
            ApartementDTO apart = (ApartementDTO)DataGridApartment.SelectedItem;

            Apartment ap = context.Apartments.FirstOrDefault(t => t.Id == apart.Id);



            foreach (var p in context.Apartments.ToList())
            {
                if (p.Id == apart.Id)
                {
                    ap.Bought = true;

                    ShopperApartment aprat = new ShopperApartment
                    {
                        ShopperId   = ShopperCopy.Id,
                        ApartmentId = ap.Id,
                    };
                    ListSA.Add(aprat);
                    context.ShopperApartment.Add(aprat);
                    break;
                }
            }
            context.SaveChanges();
            ShopperWindow WindowProg = new ShopperWindow(ShopperCopy);

            WindowProg.Show();
            this.Close();
        }
Exemple #3
0
        private void Delete_Click(object sender, RoutedEventArgs e)
        {
            ApartementDTO apart = (ApartementDTO)DataGridApartment.SelectedItem;

            foreach (var p in context.Apartments)
            {
                if (p.Id == apart.Id)
                {
                    context.Apartments.Remove(p);
                    apartments.Remove(apartments.FirstOrDefault(t => t.Id == apart.Id));
                    break;
                }
            }

            context.SaveChanges();
        }