Пример #1
0
 private void Delete_Click(object sender, RoutedEventArgs e)
 {
     using (ApartmentContext db1 = new ApartmentContext())
     {
         var apartment = db1.Apartments;
         foreach (Apartment apart in apartment)
         {
             if (int.Parse(TextBox_DeleteId.Text) == apart.Id)
             {
                 db1.Entry(apart).State = EntityState.Deleted;
             }
         }
         db1.SaveChanges();
     }
 }
Пример #2
0
 private void Add_Changes_Click(object sender, RoutedEventArgs e)
 {
     using (ApartmentContext db1 = new ApartmentContext())
     {
         var apartment = db1.Apartments;
         foreach (Apartment apart in apartment)
         {
             if (int.Parse(TextBox_ChangeApartment.Text) == apart.Id)
             {
                 apart.Area             = int.Parse(Area.Text);
                 apart.CountRoom        = int.Parse(CountRoom.Text);
                 apart.YearsBuilder     = DateTime.Parse(YearsBuilder.Text);
                 apart.TypeMaterial     = TypeMaterial.Text;
                 apart.Floor            = int.Parse(Floor.Text);
                 db1.Entry(apart).State = EntityState.Modified;
             }
         }
         db1.SaveChanges();
     }
 }