//Metodo Eliminar public void Eliminar() { try { //1.Origen de datos using (var db = new ReservaCita()) { db.Entry(this).State = EntityState.Deleted; db.SaveChanges(); } } catch (Exception eX) { throw; } }
//Metodo guardar public void Guardar() { try { //1.Origen de datos using (var db = new ReservaCita()) { if (this.especialista_id > 0) //Existe el id { db.Entry(this).State = EntityState.Modified; } else { db.Entry(this).State = EntityState.Added; } db.SaveChanges(); } } catch (Exception ex) { throw; } }