public void Delete(object primaryKey) { using (CardContext db = new CardContext()) { db.Visits.Remove(db.Visits.Find(primaryKey)); db.SaveChanges(); UpdateTable(); } }
private void Save() { using (CardContext db = new CardContext()) { visit = db.Visits.Find(visit.Id) is null?db.Visits.Add(visit) : db.Visits.Find(visit.Id); visit.DateVitis = dateVisit.SelectedDate.Value.ToString("D"); visit.IdCard = card.Id; visit.TypeVisit = primary.IsChecked.Value ? 0 : 1; visit.Diagnosis = diagnosis.Text; db.SaveChanges(); Close(); } }