public void AddTutor(TutoringSession ts) { if (ts != null) { TutorTutoringSession tmptts = new TutorTutoringSession(selectedTutor, ts); try { TutoringSessionUpdateDTO updateDTO = new TutoringSessionUpdateDTO(ts, ts); ts.Tutors.Add(tmptts); selectedTutor.TutoringSessions.Add(tmptts); dal.UpdateTutoringSession(updateDTO); Status = "Added to planned sessions"; } catch (Exception ex) { // Rollback ts.Tutors.Remove(tmptts); selectedTutor.TutoringSessions.Remove(tmptts); Status = ExceptionHandler.GetErrorMessage(ex); } NotifyPropertyChanged("TutorTutoredHours"); NotifyPropertyChanged("TutorPlannedHours"); NotifyPropertyChanged("TutorLastSession"); NotifyPropertyChanged("TutorNextSession"); NotifyPropertyChanged("AvailableTutoringSessions"); NotifyPropertyChanged("PlannedTutoringSessions"); } }
public bool Exists(TutorTutoringSession tts) { using (var context = new LabManagerDbContext()) { return(context.TutorTutoringSession.Any(x => x.Equals(tts))); } }