/// <summary>
        /// Creator: Mohamed Elamin
        /// Created On: 2020/03/10
        /// Approved By: Awaab Elamin , 2020/03/13
        /// This click event when send email button is clicked. It will send an email
        /// to the adoption application customer's email.
        /// Application ID.
        /// </summary>
        /// <remarks>
        /// Updater Name
        /// Updated: yyyy/mm/dd
        /// Update: ()
        /// </remarks>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSendEmail_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                HomeInspectorAdoptionAppointmentDecision selectedApplication =
                    (HomeInspectorAdoptionAppointmentDecision)dgAdoptionApplicationsAappointmentsList.SelectedItem;
                if (selectedApplication == null)
                {
                    MessageBox.Show("Please select an application to notify the customer by email");
                    return;
                }

                var customerEmail =
                    _inHomeInspectionAppointmentDecisionManager.GetCustomerEmailByAdoptionApplicationID(
                        selectedApplication.AdoptionApplicationID);

                MailMessage mail       = new MailMessage();
                SmtpClient  smtpServer = new SmtpClient("smtp.gmail.com");
                mail.From = new MailAddress("*****@*****.**");
                mail.To.Add(customerEmail); // getting the Customer's email from database
                mail.Subject           = "Adoption Application Status";
                mail.Body              = "Hello, your Application has been approved ";
                smtpServer.Port        = 80;
                smtpServer.Credentials = new System.Net.NetworkCredential("username", "password");
                smtpServer.EnableSsl   = true;
                //smtpServer.Send(mail);
                MessageBox.Show("Email has been sent Successfully to " + customerEmail);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Can't Send the Email", ex.Message + "\n\n"
                                + ex.InnerException.Message);
            }
        }
        public void TestEditAppointment()
        {
            bool expected = true;
            bool result;
            HomeInspectorAdoptionAppointmentDecision oldHomeInspectorAdoptionAppointmentDecision
                = new HomeInspectorAdoptionAppointmentDecision()
                {
                AppointmentID         = 100001,
                AdoptionApplicationID = 100001,
                AppointmentTypeID     = "facilitator",
                DateTime   = DateTime.Now,
                Notes      = "These are my notes",
                Decision   = "facilitator",
                LocationID = 12033,
                Active     = true
                };
            HomeInspectorAdoptionAppointmentDecision newHomeInspectorAdoptionAppointmentDecision
                = new HomeInspectorAdoptionAppointmentDecision()
                {
                AppointmentID         = 100001,
                AdoptionApplicationID = 100001,
                AppointmentTypeID     = "facilitator",
                DateTime   = DateTime.Now,
                Notes      = "These are my notes",
                Decision   = "Deny",
                LocationID = 12033,
                Active     = true
                };

            result = _inHomeInspectionAppointmentDecisionManager.EditAppointment
                         (oldHomeInspectorAdoptionAppointmentDecision,
                         newHomeInspectorAdoptionAppointmentDecision);

            Assert.AreEqual(expected, result);
        }
        /// <summary>
        /// Creator: Mohamed Elamin
        /// Created: 2020/02/19
        /// Approver: Awaab Elamin, 2020/02/21
        /// This is the Constructor method for Adoption Appliction Details
        /// window.
        /// </summary>
        /// <remarks>
        /// Updater Name
        /// Updated: yyyy/mm/dd
        /// Update: ()
        /// </remarks>
        /// <param name="homeInspectorAdoptionAppointmentDecision"></param>
        /// <param name="inHomeInspectionAppointmentDecisionManager"></param>

        public frmAdoptionApplictionDetails(HomeInspectorAdoptionAppointmentDecision
                                            homeInspectorAdoptionAppointmentDecision, IInHomeInspectionAppointmentDecisionManager
                                            inHomeInspectionAppointmentDecisionManager)
        {
            InitializeComponent();
            _homeInspectionAppointmentDecision          = homeInspectorAdoptionAppointmentDecision;
            _inHomeInspectionAppointmentDecisionManager = inHomeInspectionAppointmentDecisionManager;
        }
        /// <summary>
        /// Creator: Mohamed Elamin
        /// Created: 2020/02/19
        /// Approver: Awaab Elamin, 2020/02/21
        /// This is an Event on Save Button is clicked.
        /// </summary>
        /// <remarks>
        /// Updater Name
        /// Updated: yyyy/mm/dd
        /// Update: ()
        /// </remarks>
        /// <param name=" sender"></param>
        /// <param name=" e"></param>
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            HomeInspectorAdoptionAppointmentDecision newHomeInspectorAdoptionAppointmentDecision =
                new HomeInspectorAdoptionAppointmentDecision()
            {
                AppointmentID = Convert.ToInt32(txtAppointmentID.Text),
                Notes         = txtNotes.Text.ToString(),
                Decision      = cmbDecision.Text.ToString()
            };

            if (_addMode)
            {
                try
                {
                    if (_inHomeInspectionAppointmentDecisionManager.EditAppointment
                            (_homeInspectionAppointmentDecision, newHomeInspectorAdoptionAppointmentDecision))
                    {
                        this.NavigationService?.Navigate(new frmInHomeInspectorDecision());
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Appointment can't be Edit", ex.Message + "\n\n"
                                    + ex.InnerException.Message);
                }

                if (Facilitator.IsSelected)
                {
                    if (_inHomeInspectionAppointmentDecisionManager.UpdateHomeInspectorDecision
                            (_homeInspectionAppointmentDecision
                            .AdoptionApplicationID, Facilitator.Content.ToString()))
                    {
                        MessageBox.Show("Adoption Application's Decision has been successfully Updated");
                    }
                }

                else if (Deny.IsSelected)
                {
                    if (_inHomeInspectionAppointmentDecisionManager.UpdateHomeInspectorDecision
                            (_homeInspectionAppointmentDecision.AdoptionApplicationID
                            , Deny.Content.ToString()))

                    {
                        MessageBox.Show("Adoption Application's Decision has been Denied!");
                    }
                }
            }
            else
            {
                throw new ApplicationException("Data not Saved.",
                                               new ApplicationException("User may no longer exist."));
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Creator: Mohamed Elamin
        /// Created: 2020/04/08
        /// Approver: Austin Gee, 2020/04/09
        /// This is an Event on Cancel Adoption Application Button is clicked It
        /// changes the Adoption Appointment Decision to Cancel. Also the it changes the Adoption
        /// Appliction's Status to Cancel.
        /// </summary>
        /// <remarks>
        /// Updater Name
        /// Updated: yyyy/mm/dd
        /// Update: ()
        /// </remarks>
        /// <param name=" sender"></param>
        /// <param name=" e"></param>
        private void btnCancelApplaction_Click(object sender, RoutedEventArgs e)
        {
            HomeInspectorAdoptionAppointmentDecision newHomeInspectorAdoptionAppointmentDecision =
                new HomeInspectorAdoptionAppointmentDecision();
            AdoptionAppointmentVM selectedApplication = new AdoptionAppointmentVM();

            selectedApplication =
                (AdoptionAppointmentVM)dgAppointments.SelectedItem;
            if (selectedApplication == null)
            {
                MessageBox.Show("Please select an application to Cancel");
                return;
            }
            newHomeInspectorAdoptionAppointmentDecision.Decision      = "Cancel";
            newHomeInspectorAdoptionAppointmentDecision.AppointmentID = selectedApplication.AppointmentID;
            newHomeInspectorAdoptionAppointmentDecision.Notes         = selectedApplication.Notes;

            HomeInspectorAdoptionAppointmentDecision _homeInspectionAppointmentDecision =
                new HomeInspectorAdoptionAppointmentDecision();


            _homeInspectionAppointmentDecision.AppointmentID         = selectedApplication.AppointmentID;
            _homeInspectionAppointmentDecision.AdoptionApplicationID = selectedApplication.AdoptionApplicationID;
            _homeInspectionAppointmentDecision.LocationName          = selectedApplication.LocationName;
            _homeInspectionAppointmentDecision.AppointmentTypeID     = selectedApplication.AppointmentTypeID;
            _homeInspectionAppointmentDecision.DateTime   = selectedApplication.AppointmentDateTime;
            _homeInspectionAppointmentDecision.Notes      = selectedApplication.Notes;
            _homeInspectionAppointmentDecision.Decision   = selectedApplication.Decision;
            _homeInspectionAppointmentDecision.LocationID = selectedApplication.LocationID;
            _homeInspectionAppointmentDecision.Active     = selectedApplication.AppointmentActive;

            try
            {
                _inHomeInspectionAppointmentDecisionManager.EditAppointment
                    (_homeInspectionAppointmentDecision, newHomeInspectorAdoptionAppointmentDecision);

                if (_inHomeInspectionAppointmentDecisionManager.UpdateHomeInspectorDecision
                        (_homeInspectionAppointmentDecision
                        .AdoptionApplicationID, "Cancel"))
                {
                    MessageBox.Show("Adoption Application has been successfully cancelled ");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Appointment can't be Edited", ex.Message + "\n\n"
                                + ex.InnerException.Message);
            }
        }
        /// <summary>
        /// Creator: Mohamed Elamin
        /// Created: 2020/02/19
        /// Approver: Awaab Elamin, 2020/02/21
        /// This is an Event on Open button is clicked.
        /// </summary>
        /// <remarks>
        /// Updater Name
        /// Updated: yyyy/mm/dd
        /// Update: ()
        /// </remarks>
        /// <param name=" sender"></param>
        /// <param name=" e"></param>
        private void btnOpen_Click(object sender, RoutedEventArgs e)
        {
            HomeInspectorAdoptionAppointmentDecision selectedUser =
                (HomeInspectorAdoptionAppointmentDecision)dgAdoptionApplicationsAappointmentsList.SelectedItem;

            if (selectedUser == null)
            {
                MessageBox.Show("Please select an appliction to see the details");
                return;
            }


            this.NavigationService?.Navigate(new frmAdoptionApplictionDetails
                                                 (selectedUser, _inHomeInspectionAppointmentDecisionManager));
        }
Esempio n. 7
0
        /// <summary>
        /// Creator: Mohamed Elamin
        /// Created: 2020/02/19
        /// Approver: Awaab Elamin, 2020/02/21
        /// This method used to updates the Applications Aappointment Decision and
        ///  the in-home Inspector's notes.
        /// </summary>
        /// <remarks>
        /// Updater Mohamed Elamin
        /// Updated: 2020/04/22
        /// Update:  Fixed Comments format.
        /// </remarks>
        /// <param name="oldHomeInspectorAdoptionAppointmentDecision"></param>
        /// <param name="newHomeInspectorAdoptionAppointmentDecision"></param>
        /// <returns>True or false depending if the record was updated</returns>
        public bool EditAppointment(HomeInspectorAdoptionAppointmentDecision oldHomeInspectorAdoptionAppointmentDecision,
                                    HomeInspectorAdoptionAppointmentDecision newHomeInspectorAdoptionAppointmentDecision)
        {
            bool result = false;

            try
            {
                result = (1 == _inHomeInspectionAppointmentDecisionAccessor.UpdateAppoinment
                              (oldHomeInspectorAdoptionAppointmentDecision, newHomeInspectorAdoptionAppointmentDecision));
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Update failed.", ex);
            }
            return(result);
        }
Esempio n. 8
0
        /// <summary>
        /// Creator: Mohamed Elamin
        /// Created: 2020/02/19
        /// Approver:  Awaab Elamin, 2020/02/21
        /// This fake method is called to get a fake list of Adoption Applictions.
        /// </summary>
        /// <remarks>
        /// Updater Name
        /// Updated: yyyy/mm/dd
        /// Update: ()
        /// </remarks>
        /// <param name="oldHomeInspectorAdoptionAppointmentDecision"></param>
        /// <param name="newHomeInspectorAdoptionAppointmentDecision"></param>
        /// <returns>result</returns>
        int IInHomeInspectionAppointmentDecisionAccessor.UpdateAppoinment(HomeInspectorAdoptionAppointmentDecision oldHomeInspectorAdoptionAppointmentDecision,
                                                                          HomeInspectorAdoptionAppointmentDecision newHomeInspectorAdoptionAppointmentDecision)
        {
            int result = 0;

            foreach (HomeInspectorAdoptionAppointmentDecision HomeInspectorAdoptionAppointmentDecision in inHomeInspectionAppointmentDecisions)
            {
                if ((HomeInspectorAdoptionAppointmentDecision.AdoptionApplicationID == oldHomeInspectorAdoptionAppointmentDecision.AdoptionApplicationID) &&
                    (HomeInspectorAdoptionAppointmentDecision.AppointmentID == oldHomeInspectorAdoptionAppointmentDecision.AppointmentID) &&
                    (HomeInspectorAdoptionAppointmentDecision.Decision == oldHomeInspectorAdoptionAppointmentDecision.Decision))
                {
                    HomeInspectorAdoptionAppointmentDecision.Decision = newHomeInspectorAdoptionAppointmentDecision.Decision;
                    result++;
                }
            }
            return(result);
        }
        /// <summary>
        /// Creator: Mohamed Elamin
        /// Created: 2020/02/19
        /// Approver:  Awaab Elamin, 2020/02/21
        /// This method used to update an Adoptin Appliction decision.
        /// ID.
        /// </summary>
        /// <remarks>
        /// Updater Name
        /// Updated: yyyy/mm/dd
        /// Update: ()
        /// </remarks>
        /// <param name="oldHomeInspectorAdoptionAppointmentDecision"></param>
        /// <param name="oldHomeInspectorAdoptionAppointmentDecision"></param>
        /// <returns>Zero or one depending if the record was updated </returns>
        public int UpdateAppoinment(HomeInspectorAdoptionAppointmentDecision
                                    oldHomeInspectorAdoptionAppointmentDecision, HomeInspectorAdoptionAppointmentDecision
                                    newHomeInspectorAdoptionAppointmentDecision)
        {
            int rows = 0;
            var conn = DBConnection.GetConnection();
            var cmd  = new SqlCommand("sp_update_adoption_appointment_decision_note", conn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@AppointmentID", newHomeInspectorAdoptionAppointmentDecision
                                        .AppointmentID);

            cmd.Parameters.AddWithValue("@NewNotes",
                                        newHomeInspectorAdoptionAppointmentDecision.Notes);
            cmd.Parameters.AddWithValue("@NewDecision",
                                        newHomeInspectorAdoptionAppointmentDecision.Decision);

            cmd.Parameters.AddWithValue("@OldNotes",
                                        oldHomeInspectorAdoptionAppointmentDecision.Notes);
            cmd.Parameters.AddWithValue("@OldDecision",
                                        oldHomeInspectorAdoptionAppointmentDecision.Decision);

            try
            {
                conn.Open();
                rows = cmd.ExecuteNonQuery();
                if (rows == 0)
                {
                    throw new ApplicationException("Record not found.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
            return(rows);
        }
        /// <summary>
        /// Creator: Mohamed Elamin
        /// Created: 2020/02/19
        /// Approver:  Awaab Elamin, 2020/02/21
        /// This method used to get Adoption Applications Aappointments ByAppointmen
        ///  tType
        /// </summary>
        /// <remarks>
        /// Updater Name
        /// Updated: yyyy/mm/dd
        /// Update: ()
        /// </remarks>
        /// <returns>inHomeInspectionAppointmentDecisions List</returns>
        public List <HomeInspectorAdoptionAppointmentDecision> SelectAdoptionApplicationsAappointmentsByAppointmentType()
        {
            List <HomeInspectorAdoptionAppointmentDecision> inHomeInspectionAppointmentDecisions = new List <HomeInspectorAdoptionAppointmentDecision>();
            var conn = DBConnection.GetConnection();
            var cmd  = new SqlCommand("sp_select_inHomeInspectionAppointments_by_AppointmentType", conn);

            cmd.Connection  = conn;
            cmd.CommandType = CommandType.StoredProcedure;
            try
            {
                conn.Open();
                var reader = cmd.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        var inHomeInspectionAppointmentDecision = new HomeInspectorAdoptionAppointmentDecision();



                        inHomeInspectionAppointmentDecision.AppointmentID         = reader.GetInt32(0);
                        inHomeInspectionAppointmentDecision.AdoptionApplicationID = reader.GetInt32(1);
                        inHomeInspectionAppointmentDecision.AppointmentTypeID     = reader.GetString(2);
                        if (!reader.IsDBNull(3))
                        {
                            inHomeInspectionAppointmentDecision.DateTime = reader.GetDateTime(3);
                        }
                        if (!reader.IsDBNull(4))
                        {
                            inHomeInspectionAppointmentDecision.Notes = reader.GetString(4);
                        }
                        else
                        {
                            inHomeInspectionAppointmentDecision.Notes = "";
                        }
                        if (!reader.IsDBNull(5))
                        {
                            inHomeInspectionAppointmentDecision.Decision = reader.GetString(5);
                        }
                        else
                        {
                            inHomeInspectionAppointmentDecision.Decision = "";
                        }

                        inHomeInspectionAppointmentDecision.LocationName =
                            RetrieveLocationNameByLocationID(reader.GetInt32(6));
                        inHomeInspectionAppointmentDecision.Active = reader.GetBoolean(7);

                        inHomeInspectionAppointmentDecisions.Add(inHomeInspectionAppointmentDecision);
                    }
                }
                reader.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
            return(inHomeInspectionAppointmentDecisions);
        }