public void TestCreateTerms() { SqlCalendar sql = new SqlCalendar(); IEnumerable <ClassCalendar> querycal = from elem in sql.CalendarList() where elem.Month == 2 select elem; ClassCalendar calendar = querycal.First(); sql.CreateTerms("('08:00:00','12:00:00','2000-2-1',3,1,100,1),('13:00:00','15:00:00','2000-2-2',4,2,200,2)"); ClassGenerateCalendar.ShareCalendar(calendar, sql); List <ClassTerm> list = sql.ListOfTerms(); IEnumerable <ClassTerm> query = from elem in list where elem.TermId == 3 && elem.CalendarDay.CalendarDayId == 1 && elem.Doctor.Doctor_id == 1 && elem.StartTime.CompareTo(new TimeSpan(8, 0, 0)) == 0 && elem.EndTime.CompareTo(new TimeSpan(12, 0, 0)) == 0 select elem; Assert.Single(query); query = from elem in list where elem.TermId == 4 && elem.CalendarDay.CalendarDayId == 2 && elem.Doctor.Doctor_id == 2 && elem.StartTime.CompareTo(new TimeSpan(13, 0, 0)) == 0 && elem.EndTime.CompareTo(new TimeSpan(15, 0, 0)) == 0 select elem; Assert.Single(query); querycal = from elem in sql.CalendarList() where elem.Month == 2 select elem; calendar = querycal.First(); Assert.Equal(2, calendar.Status.StatusId); }
//Share calendar private void ButtonShare_Click(object sender, RoutedEventArgs e) { try { ClassCalendar calendar = GetCalendarForSelectedCalendarInComboboxFromDataBase(); if (calendar.Status.StatusId != sql.SelectStatusId(EnumStatus.New)) { throw new Exception("Calendar status must be new"); } ClassGenerateCalendar.ShareCalendar(calendar, sql); MessageBox.Show("Succesfully shared calendar"); ComboBoxPickDate.ItemsSource = sql.CalendarList(); if (ComboBoxPickDate.Items.Count == 0) { return; } ComboBoxPickDate.SelectedIndex = ComboBoxPickDate.Items.Count - 1; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } }