Beispiel #1
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();
        }
Beispiel #2
0
        private void ClickSignIn(object sender, RoutedEventArgs e)
        {
            int RealtorCheck = 0;
            int ShopperCheck = 0;

            foreach (var item in Context.Realtors.ToList())
            {
                if (item.Name == TextBoxUserName.Text &&
                    item.Password == TextBoxPassword.Text)
                {
                    Window1 WindowProg = new Window1(item.Id);
                    WindowProg.Show();
                    MessageBox.Show($"Welcom {item.Name}");
                    RealtorCheck = 3;
                    break;
                }
                if (item.Name == TextBoxUserName.Text &&
                    item.Password != TextBoxPassword.Text)
                {
                    RealtorCheck = 2;
                    break;
                }
            }
            if (RealtorCheck == 2)
            {
                MessageBox.Show($"Invalid password");
                RealtorCheck = 3;
            }
            if (RealtorCheck != 3)
            {
                foreach (var item in Context.Shoppers.ToList())
                {
                    if (item.Name == TextBoxUserName.Text &&
                        item.Password == TextBoxPassword.Text)
                    {
                        ShopperWindow WindowProg = new ShopperWindow(item);
                        WindowProg.Show();
                        MessageBox.Show($"Welcom {item.Name}");
                        ShopperCheck = 3;
                        break;
                    }
                    if (item.Name == TextBoxUserName.Text &&
                        item.Password != TextBoxPassword.Text)
                    {
                        ShopperCheck = 2;
                        break;
                    }
                }
                if (ShopperCheck == 2)
                {
                    MessageBox.Show($"Invalid password");
                }
                if (ShopperCheck == 0)
                {
                    MessageBox.Show($"{TextBoxUserName.Text} there is no such user");
                }
            }
        }