Ejemplo n.º 1
0
        public void TestShiftTimeManagerInsertShiftTimeTests()
        {
            //arrange
            PetUniverseShiftTime shiftTime = new PetUniverseShiftTime();

            shiftTime.DepartmentID = "Shipping/Receiving";
            shiftTime.StartTime    = "14:00:00";
            shiftTime.EndTime      = "22:00:00";
            bool test;
            IShiftTimeManager shiftTimeManager = new ShiftTimeManager(_shiftTimeAccessor);

            //act
            test = shiftTimeManager.AddShiftTime(shiftTime);

            //assert
            Assert.IsTrue(test);
        }
        /// <summary>
        /// Creator: Jordan Lindo
        /// Created: 2/15/2020
        /// Approver: Alex Diers
        ///
        /// This button click listener sends the data for creating a new department record to the logic layer
        /// </summary>
        /// <remarks>
        /// Updater: NA
        /// Updated: NA
        /// Update: NA
        ///
        /// </remarks>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddDepartmentSave_Click(object sender, RoutedEventArgs e)
        {
            string departmentID = txtAddDepartmentDepartmentName.Text;
            string description  = txtAddDepartmentDescription.Text;

            if (ValidateERole.checkDepartmentID(departmentID) && ValidateERole.checkDescription(description))
            {
                try
                {
                    if (_departmentManager.AddDepartment(departmentID, description))
                    {
                        ShiftTimeManager _shiftTimeManger = new ShiftTimeManager();
                        try
                        {
                            foreach (PetUniverseShiftTime shiftTime in DEFAULT_SHIFTTIMES)
                            {
                                shiftTime.DepartmentID = departmentID;
                                _shiftTimeManger.AddShiftTime(shiftTime);
                            }
                        }
                        catch (Exception ex)
                        {
                            WPFErrorHandler.ErrorMessage("failed to save departments Default Shift Times. " + ex.Message);
                        }

                        WPFErrorHandler.SuccessMessage("Department added, with default shift times");
                        canAddDepartment.Visibility  = Visibility.Hidden;
                        canDepartmentList.Visibility = Visibility.Visible;
                        showDGDepartments();
                    }
                    else
                    {
                        WPFErrorHandler.ErrorMessage("Department not added.");
                    }
                }
                catch (Exception ex)
                {
                    WPFErrorHandler.ErrorMessage("Department failed to save. " + ex.Message);
                }
            }