/// <summary> /// Method that creates a new Employee and stores it in the table /// </summary> /// <param name="empRoles">Object holding the data to add to the table</param> /// <returns> Row Count </returns> public int InsertEmpRole(EmpRoles empRoles) { int rows = 0; var conn = DBConnection.GetDbConnection(); var cmdText = @"sp_insert_roles"; var cmd = new SqlCommand(cmdText, conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@RoleID", empRoles.RoleID); cmd.Parameters.AddWithValue("@Description", empRoles.Description); try { conn.Open(); rows = cmd.ExecuteNonQuery(); } catch (Exception) { throw; } finally { conn.Close(); } return(rows); }
/// <summary> /// Verifies that the fields are filled out and creates a emp role object /// </summary> private bool createNewEmpRole() { if (txtRoleID.Text == "" || txtDescription.Text == "") { MessageBox.Show("You must fill out all the fields."); } else if (txtRoleID.Text.Length > 50 || txtDescription.Text.Length > 250) { MessageBox.Show("Your Role Name is too long! Please shorten it."); } else if (txtDescription.Text.Length > 250) { MessageBox.Show("Your description is too long! Please shorten it."); } else { result = true; //Valid _empRole = new EmpRoles() { RoleID = txtRoleID.Text, Description = txtDescription.Text, }; } return(result); }
public int InsertEmpRole(EmpRoles empRoles) { int listLength = role.Count; role.Add(empRoles); if (listLength == role.Count - 1) { return(1); } else { return(0); } }
public void TestCreaterolesDescriptionTooLong() { // arrange EmpRoles testroles = new EmpRoles() { RoleID = "GoodID", Description = createLongString(1001), }; string badDescription = testroles.Description; // act bool result = rolesManager.CreateRole(testroles); // assert - check that description did not change Assert.AreEqual(badDescription, testroles.Description); }
public void TestCreaterolesrolesIDTooLong() { // arrange EmpRoles testroles = new EmpRoles() { RoleID = createLongString(51), Description = "Good Description", }; string badrolesID = testroles.RoleID; // act bool result = rolesManager.CreateRole(testroles); // assert - check that rolesID did not change Assert.AreEqual(badrolesID, testroles.RoleID); }
/// <summary author="Austin Berquam" created="2019/01/26"> /// Method that sends the created role to the accessor /// </summary> /// <param name="newRole">Object holding the new role to add to the table</param> /// <returns> Row Count </returns> public bool CreateRole(EmpRoles newRole) { ValidationExtensionMethods.ValidateID(newRole.RoleID); ValidationExtensionMethods.ValidateDescription(newRole.Description); bool result = false; try { result = (1 == empRolesAccessor.InsertEmpRole(newRole)); } catch (Exception ex) { ExceptionLogManager.getInstance().LogException(ex); throw ex; } return(result); }
public void TestCreaterolesValidInputMaxLengths() { bool expectedResult = true; bool actualResult; // arrange EmpRoles testroles = new EmpRoles() { RoleID = createLongString(50), Description = createLongString(1000), }; // act actualResult = rolesManager.CreateRole(testroles); // assert - check if roles was added Assert.AreEqual(expectedResult, actualResult); }
public void TestCreaterolesValidInput() { bool expectedResult = true; bool actualResult; // arrange EmpRoles testroles = new EmpRoles() { RoleID = "GoodID", Description = "Good Description", }; // act actualResult = rolesManager.CreateRole(testroles); // assert - check if roles was added Assert.AreEqual(expectedResult, actualResult); }