예제 #1
0
        private void ButtonCreate_Click(object sender, RoutedEventArgs e)
        {
            SaveInputInformation();
            DateTime startDate = new DateTime(selectedYear, selectedMonth, selectedDay, startHour, startMinute, DateSeconds);
            DateTime endDate   = new DateTime(selectedYear, selectedMonth, selectedDay, endHour, endMinute, DateSeconds);

            selectedUsersAppointments = Utils.GetParticipantsAppointments(selectedUsers, appointmentDatabase);

            if (Utils.IsAppointmentInputValid(startDate, endDate, selectedUsersAppointments))
            {
                appointment = new Appointment();
                CreateAppointmentsObject(appointment);
                appointmentDatabase.Serialize(PathToAppointmentsFile);
                this.Close();
            }
            else
            {
                MessageBox.Show(ErrorMessage, MessageTitle);
            }
        }
예제 #2
0
        public void DeserializeAppointmentsFile_FileExists_ReturnedDatabaseContainsTestAppointment()
        {
            user        = new User("test");
            appointment = new Appointment()
            {
                StartDate   = testStartDate,
                EndDate     = testEndDate,
                Creator     = user,
                Title       = "Title",
                Description = "Description"
            };

            appointment.Participants.Add(user);

            appointmentDatabase = new AppointmentDatabase();
            appointmentDatabase.Appointments.Add(appointment);
            appointmentDatabase.Serialize(PathToAppointmentsTestFile);

            bool isAppointmentInDatabase = Utils.DeserializeAppointmentsFile(PathToAppointmentsTestFile).Appointments.Exists(
                a => a.Title == appointment.Title && a.Creator.Name == appointment.Creator.Name);

            Assert.IsTrue(isAppointmentInDatabase);
        }
 private void ButtonDelete_Click(object sender, RoutedEventArgs e)
 {
     selectedAppointment = ListBoxMyAppointments.SelectedItem as Appointment;
     appointmentDatabase.Appointments.Remove(selectedAppointment);
     appointmentDatabase.Serialize(PathToAppointmentsFile);
 }