예제 #1
0
        public void TestUpdateHouseKeepingRequestValidDescription()
        {
            //Arrange
            HouseKeepingRequest newHouseKeepingRequest = new HouseKeepingRequest();

            setHouseKeepingRequests(_houseKeepingRequests[0], newHouseKeepingRequest);
            string newDescription = "This test is updating the description in TestUpdateHouseKeepingRequestValidDescription()";

            newHouseKeepingRequest.Description = newDescription;
            //Act
            _houseKeepingRequestManager.EditHouseKeepingRequest(_houseKeepingRequests[0], newHouseKeepingRequest);
            //Assert
            _houseKeepingRequests = _houseKeepingRequestManager.RetrieveAllHouseKeepingRequests();
            Assert.AreEqual(_houseKeepingRequestManager.RetrieveHouseKeepingRequest(_houseKeepingRequests[0].HouseKeepingRequestID).Description, newDescription);
        }
예제 #2
0
        /// <summary>
        /// Author: Dalton Cleveland
        /// Created : 3/27/2019
        /// The function which runs when Save is clicked
        /// </summary>
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (((string)btnSave.Content) == "Submit")
            {
                if (!ValidateInput())
                {
                    return;
                }
                HouseKeepingRequest newHouseKeepingRequest = new HouseKeepingRequest();
                newHouseKeepingRequest.Active         = (bool)chkActive.IsChecked;
                newHouseKeepingRequest.BuildingNumber = int.Parse(txtBuildingNumber.Text);
                newHouseKeepingRequest.RoomNumber     = int.Parse(txtRoomNumber.Text);
                newHouseKeepingRequest.Description    = txtDescription.Text;
                try
                {
                    if (_existingHouseKeepingRequest == null)
                    {
                        _houseKeepingRequestManager.AddHouseKeepingRequest(newHouseKeepingRequest);
                        SetError("");
                        MessageBox.Show("House Keeping Request Created Successfully: " +
                                        "\nBuildingNumber: " + newHouseKeepingRequest.BuildingNumber +
                                        "\nRoomNumber: " + newHouseKeepingRequest.RoomNumber +
                                        "\nDescription: " + newHouseKeepingRequest.Description);
                    }
                    else
                    {
                        newHouseKeepingRequest.Active            = (bool)chkActive.IsChecked;
                        newHouseKeepingRequest.WorkingEmployeeID = int.Parse(txtWorkingEmployee.Text);
                        _houseKeepingRequestManager.EditHouseKeepingRequest(_existingHouseKeepingRequest, newHouseKeepingRequest);
                        SetError("");
                        MessageBox.Show("House Keeping Request Updated Successfully: " +
                                        "\nOld BuildingNumber: " + _existingHouseKeepingRequest.BuildingNumber +
                                        "\nOld RoomNumber: " + _existingHouseKeepingRequest.RoomNumber +
                                        "\nOld Description: " + _existingHouseKeepingRequest.Description +
                                        "\n" +
                                        "\nNew BuidlingNumber: " + newHouseKeepingRequest.BuildingNumber +
                                        "\nNew RoomNumber: " + newHouseKeepingRequest.RoomNumber +
                                        "\nNew Description: " + newHouseKeepingRequest.Description +
                                        "\nNew WorkingEmployeeID: " + newHouseKeepingRequest.WorkingEmployeeID);
                    }
                }
                catch (Exception ex)
                {
                    SetError(ex.Message);
                }

                Close();
            }
            else if (((string)btnSave.Content) == "Update")
            {
                setEditable();
            }
            else
            {
                MessageBox.Show(btnSave.Content.GetType() + " " + btnSave.Content);
            }
        }