예제 #1
0
        public void TestAppointmentRetrieveById()
        {
            // arrange
            AppointmentLocationVM appointment;
            IAppointmentManager   appointmentManager  = new AppointmentManager(_appointmentAccessor);
            AppointmentLocationVM selectedAppointment = new AppointmentLocationVM()
            {
                AppointmentID         = 1,
                AdoptionApplicationID = 1,
                AppointmentTypeID     = "InHomeInspection",
                DateTime         = new DateTime(2020, 5, 1, 12, 30, 00),
                Notes            = "",
                Decicion         = "Undecided",
                LocationID       = 1,
                Active           = true,
                LocationName     = "Home",
                LocationAddress1 = "123 Real Ave",
                LocationCity     = "Marion",
                LocationState    = "IA",
                LocationZip      = "52402"
            };

            // act
            appointment = appointmentManager.RetrieveAppointmentByID(selectedAppointment.AppointmentID);

            // assert
            // Assert.AreEqual(selectedAppointment, appointment);
            Assert.AreEqual(selectedAppointment.AppointmentID, appointment.AppointmentID);
        }
예제 #2
0
        public void TestAppointmentRemove()
        {
            // arrange
            int result = 0;
            AppointmentLocationVM appointment = new AppointmentLocationVM()
            {
                AppointmentID         = 1,
                AdoptionApplicationID = 1,
                AppointmentTypeID     = "InHomeInspection",
                DateTime         = new DateTime(2020, 5, 1, 12, 30, 00),
                Notes            = "",
                Decicion         = "Undecided",
                LocationID       = 1,
                LocationName     = "Home",
                LocationAddress1 = "123 Real Ave",
                LocationCity     = "Marion",
                LocationState    = "IA",
                LocationZip      = "52402"
            };
            IAppointmentManager appointmentManager = new AppointmentManager(_appointmentAccessor);

            // act
            result = appointmentManager.RemoveAppointment(appointment);

            // assert
            Assert.AreEqual(1, result);
        }
예제 #3
0
        /// <summary>
        /// Creator: Thomas Dupuy
        /// Created: 2020/02/06
        /// Approver: Awaab Elamin
        /// This method selects all appointments
        /// </summary>
        /// <remarks>
        /// Updater: Thomas Dupuy
        /// Updated: 2020/04/12
        /// Update: Updated it to match the AppointmentLocationVM instead on the Appointment DTO
        ///
        /// Updater: Mohamed Elamin
        /// Updated: 2020/04/20
        /// Update: I Added param, returns tags for the comments.
        /// And updated the date format.
        /// </remarks>
        /// <returns>A list of active appointments</returns>
        public List <AppointmentLocationVM> SelectAllActiveAppointments()
        {
            List <AppointmentLocationVM> appointments = new List <AppointmentLocationVM>();
            var conn = DBConnection.GetConnection();
            var cmd  = new SqlCommand("sp_select_all_appointments_by_active");

            cmd.Connection  = conn;
            cmd.CommandType = CommandType.StoredProcedure;
            try
            {
                conn.Open();

                var reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    AppointmentLocationVM newAppointment = new AppointmentLocationVM();
                    newAppointment.AppointmentID         = reader.GetInt32(0);
                    newAppointment.AdoptionApplicationID = reader.GetInt32(1);
                    newAppointment.AppointmentTypeID     = reader.GetString(2);
                    newAppointment.DateTime         = reader.GetDateTime(3);
                    newAppointment.Notes            = reader.IsDBNull(4) ? null : reader.GetString(4);
                    newAppointment.Decicion         = reader.GetString(5);
                    newAppointment.LocationID       = reader.GetInt32(6);
                    newAppointment.Active           = reader.GetBoolean(7);
                    newAppointment.LocationName     = reader.GetString(8);
                    newAppointment.LocationAddress1 = reader.GetString(9);
                    newAppointment.LocationAddress2 = reader.IsDBNull(10) ? null : reader.GetString(10);
                    newAppointment.LocationCity     = reader.GetString(11);
                    newAppointment.LocationState    = reader.GetString(12);
                    newAppointment.LocationZip      = reader.GetString(13);
                    appointments.Add(newAppointment);
                }
                reader.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
            return(appointments);
        }
예제 #4
0
        public ActionResult CreateInterview(AppointmentLocationVM appointmentLocationVM)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    Location location = new Location()
                    {
                        LocationID = appointmentLocationVM.LocationID,
                        Name       = appointmentLocationVM.LocationName,
                        Address1   = appointmentLocationVM.LocationAddress1,
                        Address2   = appointmentLocationVM.LocationAddress2,
                        City       = appointmentLocationVM.LocationCity,
                        State      = appointmentLocationVM.LocationState,
                        Zip        = appointmentLocationVM.LocationZip
                    };
                    _locationManager.AddLocation(location);

                    Appointment appointment = new Appointment()
                    {
                        AppointmentID         = appointmentLocationVM.AppointmentID,
                        AdoptionApplicationID = appointmentLocationVM.AdoptionApplicationID,
                        AppointmentTypeID     = "Interview",
                        DateTime   = appointmentLocationVM.DateTime,
                        LocationID = appointmentLocationVM.LocationID
                    };
                    _appointmentManager.AddAppointment(appointment);

                    return(RedirectToAction("Index"));
                }
                catch
                {
                    return(View());
                }
            }
            return(View());
        }
예제 #5
0
        /// <summary>
        /// Creator: Thomas Dupuy
        /// Created: 2020/04/12
        /// Approver: Michael Thompson
        /// This method selects an appointment by its id
        /// </summary>
        /// <remarks>
        /// Updater: Mohamed Elamin
        /// Updated: 2020/04/20
        /// Update: I Added param, returns tags for the comments.
        /// And updated the date format.
        /// </remarks>
        /// <param name="id"></param>
        /// <returns> An appointment by appointment ID</returns>
        public AppointmentLocationVM SelectAppointmentByID(int id)
        {
            AppointmentLocationVM appointment = new AppointmentLocationVM();
            var conn = DBConnection.GetConnection();
            var cmd1 = new SqlCommand("sp_select_appointment_by_appointment_id");
            var cmd2 = new SqlCommand("sp_select_location_by_location_id");

            cmd1.Connection  = conn;
            cmd2.Connection  = conn;
            cmd1.CommandType = CommandType.StoredProcedure;
            cmd2.CommandType = CommandType.StoredProcedure;
            cmd1.Parameters.AddWithValue("@AppointmentID", id);
            cmd2.Parameters.Add("@LocationID", SqlDbType.Int);
            try
            {
                conn.Open();
                var reader1 = cmd1.ExecuteReader();

                if (reader1.Read())
                {
                    appointment.AppointmentID         = id;
                    appointment.AdoptionApplicationID = reader1.GetInt32(1);
                    appointment.AppointmentTypeID     = reader1.GetString(2);
                    appointment.DateTime   = reader1.GetDateTime(3);
                    appointment.Notes      = reader1.GetString(4);
                    appointment.Decicion   = reader1.GetString(5);
                    appointment.LocationID = reader1.GetInt32(6);
                    appointment.Active     = reader1.GetBoolean(7);
                }
                else
                {
                    throw new ApplicationException("User not found.");
                }
                cmd2.Parameters["@LocationID"].Value = appointment.LocationID;

                var reader2 = cmd2.ExecuteReader();

                if (reader2.Read())
                {
                    appointment.LocationName     = reader2.GetString(1);
                    appointment.LocationAddress1 = reader2.GetString(2);
                    appointment.LocationAddress2 = reader2.GetString(3);
                    appointment.LocationCity     = reader2.GetString(4);
                    appointment.LocationState    = reader2.GetString(5);
                    appointment.LocationZip      = reader2.GetString(6);
                }
                else
                {
                    throw new ApplicationException("Location not found.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
            return(appointment);
        }