/// <summary>
        /// Creator: Lane Sandburg
        /// Created: 04/09/2020
        /// Approver: Jordan Lindo
        ///
        /// populates list and datagrid with created availabilities.
        /// </summary>
        /// <remarks>
        /// Updater:
        /// Updated:
        /// Update:
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddToDataGrid_Click(object sender, RoutedEventArgs e)
        {
            EmployeeAvailability availability = new EmployeeAvailability();

            try
            {
                if (cboDayOfWeek.SelectedItem == null)
                {
                    WPFErrorHandler.ErrorMessage("Day cannot be blank", "Validation");
                    cboDayOfWeek.Focus();
                    return;
                }
                else
                {
                    availability.DayOfWeek = cboDayOfWeek.SelectedItem.ToString();
                }
            }
            catch (Exception ex)
            {
                WPFErrorHandler.ErrorMessage(ex.Message, "Validation");
            }

            try
            {
                if (TPStartTime.Value == null || TPStartTime.Value.ToString().Equals(""))
                {
                    WPFErrorHandler.ErrorMessage("StartTime cannot be blank", "Validation");
                    TPStartTime.Focus();
                    return;
                }
                else
                {
                    DateTime time = (DateTime)TPStartTime.Value;
                    availability.StartTime = time.ToString("HH:mm:ss");;
                }
            }
            catch (Exception ex)
            {
                WPFErrorHandler.ErrorMessage(ex.Message, "Validation");
            }

            try
            {
                if (TPEndTime.Value == null || TPEndTime.Value.ToString().Equals(""))
                {
                    WPFErrorHandler.ErrorMessage("EndTime cannot be blank", "Validation");
                    TPEndTime.Focus();
                    return;
                }
                else
                {
                    DateTime time = (DateTime)TPEndTime.Value;
                    availability.EndTime = time.ToString("HH:mm:ss");
                }
            }
            catch (Exception ex)
            {
                WPFErrorHandler.ErrorMessage(ex.Message, "Validation");
            }
            try
            {
                DateTime startTime = (DateTime)TPStartTime.Value;
                DateTime endTime   = (DateTime)TPEndTime.Value;
                if (endTime <= startTime.AddMinutes(59))
                {
                    MessageBox.Show("Shifts must be at least 1Hour.");
                    TPStartTime.Focus();
                    return;
                }
            }
            catch (Exception ex)
            {
                WPFErrorHandler.ErrorMessage(ex.Message, "Validation");
            }

            try
            {
                availability.EmployeeID = _employeeAvailabilityManager.RetrieveLastEmployeeID();
            }
            catch (Exception ex)
            {
                WPFErrorHandler.ErrorMessage(ex.Message, "Validation");
            }

            try
            {
                List <EmployeeAvailability> newAvailabilities = new List <EmployeeAvailability>();
                bool failed = false;
                if (availabilities.Count != 0)
                {
                    foreach (EmployeeAvailability addedAvailability in availabilities)
                    {
                        if (availability.DayOfWeek == addedAvailability.DayOfWeek &&
                            availability.StartTime == addedAvailability.StartTime &&
                            availability.EndTime == addedAvailability.EndTime)
                        {
                            WPFErrorHandler.ErrorMessage("availability " + availability.DayOfWeek.ToString() + " " + availability.StartTime.ToString() + " " + availability.EndTime.ToString() + "  was a duplicate entry", "Validation");
                            failed = true;
                        }
                        else if (availability.DayOfWeek == addedAvailability.DayOfWeek)
                        {
                            DateTime newStartTime   = DateTime.Parse(availability.StartTime);
                            DateTime newEndTime     = DateTime.Parse(availability.EndTime);
                            DateTime addedEndTime   = DateTime.Parse(addedAvailability.EndTime);
                            DateTime addedStartTime = DateTime.Parse(addedAvailability.StartTime);

                            if (newStartTime < addedEndTime)
                            {
                                if (newEndTime < addedStartTime != true)
                                {
                                    WPFErrorHandler.ErrorMessage("current availability " + availability.DayOfWeek.ToString() + " " + availability.StartTime.ToString() + " " + availability.EndTime.ToString() + " overlaps with "
                                                                 + addedAvailability.DayOfWeek.ToString() + " " + addedAvailability.StartTime.ToString() + " " + addedAvailability.EndTime.ToString(), "Validation");
                                    failed = true;
                                }
                                else
                                {
                                    newAvailabilities.Add(availability);
                                }
                            }
                            else
                            {
                                newAvailabilities.Add(availability);
                            }
                        }
                        else
                        {
                            newAvailabilities.Add(availability);
                        }
                    }
                }
                else
                {
                    newAvailabilities.Add(availability);
                }
                if (failed == false)
                {
                    availabilities.Add(newAvailabilities[0]);
                }
            }
            catch (Exception ex)
            {
                WPFErrorHandler.ErrorMessage(ex.Message, "Validation");
            }

            dgAvailability.Items.Refresh();

            if (btnSaveAvail.IsEnabled != true)
            {
                btnSaveAvail.IsEnabled = true;
            }
        }
        /// <summary>
        /// Creator: Lane Sandburg
        /// Created: 02/07/2019
        /// Approver: Alex Diers
        ///
        /// click handler for the save button
        /// </summary>
        /// <remarks>
        /// Updater: NA
        /// Updated: NA
        /// Update: NA
        /// </remarks>
        private void btnShiftTimeSave_Click(object sender, RoutedEventArgs e)
        {
            DateTime         startTime = (DateTime)TPStartTime.Value;
            DateTime         endTime   = (DateTime)TPEndTime.Value;
            MessageBoxResult result    = MessageBox.Show("Are You Sure?", "Pet Universe", MessageBoxButton.YesNoCancel);

            switch (result)
            {
            case MessageBoxResult.Yes:
                if (cboShiftTimeDepartment.Text.ToString() == "" || cboShiftTimeDepartment.Text.ToString() == null)
                {
                    MessageBox.Show("Please Select a Department.");
                    return;
                }
                if (TPStartTime.Text.ToString() == "" || TPStartTime.Text.ToString() == null)
                {
                    MessageBox.Show("Please Select a Shift Start Time.");
                    TPStartTime.Focus();
                    return;
                }
                if (TPEndTime.Text.ToString() == "" || TPEndTime.Text.ToString() == null)
                {
                    MessageBox.Show("Please Select a Shift End Time.");
                    TPEndTime.Focus();
                    return;
                }
                if (TPStartTime.Text.ToString() == TPEndTime.Text.ToString())
                {
                    MessageBox.Show("Shifts must be at least 1Hour.");
                    TPStartTime.Focus();
                    return;
                }
                if (endTime < startTime.AddHours(1))
                {
                    MessageBox.Show("Shifts must be at least 1Hour.");
                    TPStartTime.Focus();
                    return;
                }


                PetUniverseShiftTime shiftTime = new PetUniverseShiftTime()
                {
                    DepartmentID = cboShiftTimeDepartment.Text.ToString(),
                    StartTime    = TPStartTime.Text.ToString(),
                    EndTime      = TPEndTime.Text.ToString()
                };
                if (btnShiftTimeEdit.IsEnabled == false)
                {
                    try
                    {
                        if (_shiftTimeManager.AddShiftTime(shiftTime))
                        {
                            PopulateShiftTimes();
                            ResetControls();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message + "\n" + ex.InnerException.Message);
                    }
                }
                else
                {
                    try
                    {
                        if (_shiftTimeManager.EditShiftTime(_shiftTime = (PetUniverseShiftTime)dgShiftTime.SelectedItem, shiftTime))
                        {
                            PopulateShiftTimes();
                            ResetControls();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message + "\n" + ex.InnerException.Message);
                    }
                }

                PopulateShiftTimes();
                ResetControls();
                break;

            case MessageBoxResult.No:
                MessageBox.Show("Okay", "PetUniverse");
                break;

            case MessageBoxResult.Cancel:
                MessageBox.Show("Canceled.", "PetUniverse");
                break;
            }
        }