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 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.");
            }
        }