public void AddTimeslot(TimeSlot slot) { using (GymContext db = new GymContext()) { try { // add and save db.TimeSlots.Add(slot); db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e.ToString()); } } }
public void AddTrainer(Trainer trainer) { using (GymContext db = new GymContext()) { try { // add and save db.Trainers.Add(trainer); db.SaveChanges(); // navigation properties updated on both sides } catch (Exception e) { Console.WriteLine(e.ToString()); } } }