public void CreateUpdateSaveDeleteAppointmentTest()
        {
            int      customerId  = 1;
            int      userId      = 0;
            string   title       = "Test Appointment";
            string   description = "Test Descriptiton";
            string   location    = "Test Location";
            string   contact     = "Test contact";
            string   type        = "Test Type";
            string   url         = "Test.url.com";
            DateTime start       = DateTime.UtcNow;
            DateTime end         = DateTime.UtcNow;

            end.AddDays(1);
            DateTime createdDate  = DateTime.Now;
            string   createdBy    = "system";
            DateTime modifiedDate = DateTime.Now;
            string   modifiedBy   = "system";

            Appointment appt = AppointmentDao.CreateNewAppointment(customerId,
                                                                   userId,
                                                                   title,
                                                                   description,
                                                                   location,
                                                                   contact,
                                                                   type,
                                                                   url,
                                                                   start,
                                                                   end,
                                                                   createdDate,
                                                                   createdBy,
                                                                   modifiedDate,
                                                                   modifiedBy);

            Assert.IsInstanceOfType(appt, typeof(Appointment));
            Assert.IsTrue(appt.Title == title);
            Assert.IsTrue(appt.CreateDate == createdDate);

            bool saved = AppointmentDao.SaveAppointment(appt);

            Assert.IsTrue(saved == true);

            appt.Title = "Updated Test Title";
            bool update = AppointmentDao.UpdateAppointment(appt);

            Assert.IsTrue(update == true);

            bool delete = AppointmentDao.DeleteAppointment(appt);

            Assert.IsTrue(delete == true);
        }
Exemple #2
0
        private void AddApptButton_Click(object sender, EventArgs e)
        {
            int      customerId = Convert.ToInt32(CustomerAptComboBox.SelectedValue);
            int      userId     = UserDao.GetUserIdByName(LoginForm.username);
            bool     saved      = false;
            DateTime start      = DateTimeOffset.Parse(StartDateDatePicker.Text).UtcDateTime;
            DateTime end        = DateTimeOffset.Parse(EndDateDatePicker.Text).UtcDateTime;;

            if (start.Hour >= 9 && start.Hour <= 17 && end.Hour >= 9 && end.Hour <= 17)
            {
                var newAppt = AppointmentDao.CreateNewAppointment(customerId,
                                                                  userId,
                                                                  TitleApptTextBox.Text,
                                                                  DescriptionText.Text,
                                                                  LocationText.Text,
                                                                  ContactText.Text,
                                                                  TypeText.Text,
                                                                  UrlText.Text,
                                                                  start,
                                                                  end,
                                                                  DateTime.UtcNow,
                                                                  LoginForm.username,
                                                                  DateTime.UtcNow,
                                                                  LoginForm.username);
                saved = AppointmentDao.SaveAppointment(newAppt);
            }
            else
            {
                MessageBox.Show("Please select a time within business hours.");
                return;
            }

            if (saved == true)
            {
                MessageBox.Show("Appointment was saved successfully!");
                SetDefaults();
            }
            else if (saved == false)
            {
                MessageBox.Show("Appointment wasn't able to save.");
            }
        }
Exemple #3
0
        private void UpdateApptButton_Click(object sender, EventArgs e)
        {
            int      apptId     = Convert.ToInt32(AppointmentsComboBox.SelectedValue);
            int      customerId = Convert.ToInt32(CustomerUpdateComboBox.SelectedValue);
            int      userId     = UserDao.GetUserIdByName(LoginForm.username);
            DateTime start      = DateTimeOffset.Parse(StartDateUpdateDatePicker.Text).UtcDateTime;
            DateTime end        = DateTimeOffset.Parse(EndDateUpdateDatePicker.Text).UtcDateTime;;

            var newAppt = AppointmentDao.CreateNewAppointment(customerId,
                                                              userId,
                                                              TitleUpdateText.Text,
                                                              DescriptionUpdateText.Text,
                                                              LocationUpdateText.Text,
                                                              ContactUpdateText.Text,
                                                              TypeUpdateText.Text,
                                                              UrlUpdateText.Text,
                                                              start,
                                                              end,
                                                              DateTime.UtcNow,
                                                              LoginForm.username,
                                                              DateTime.UtcNow,
                                                              LoginForm.username);

            newAppt.AppointmentId = apptId;
            bool update = AppointmentDao.UpdateAppointment(newAppt);

            if (update == true)
            {
                MessageBox.Show("Appointment was updated successfully!");
                SetDefaults();
            }
            else if (update == false)
            {
                MessageBox.Show("Appointment wasn't able to update.");
            }
        }