/// <summary> /// Create a new role. /// </summary> /// <param name="role">Role that you want to create.</param> public void CreateRole(String roleName) { Role newRole = new Role(); newRole.Role_Name = roleName; newRole.Role_IsDelete = false; //Check role name is exists. if (RD.GetRole(newRole.Role_Name) != null) { throw new Exception("This role is existed."); } int result = RD.CreateRole(newRole); if (result == -1) { throw new Exception("An error occurred while executing this operation."); } }
/// <summary> /// Create new a role. /// </summary> /// <param name="role">Role that you want to create.</param> /// <returns>Return the number of rows affected or return -1 if occur exception.</returns> public int CreateRole(Role role) { return DBHelper.Instance.Insert(role); }
/// <summary> /// Update a role. /// </summary> /// <param name="role">Role that you want to update.</param> /// <returns>Return the number of rows affected or return -1 if occur exception.</returns> public int UpdateRole(Role role) { return DBHelper.Instance.Update(role, String.Format("Role_Name = '{0}'", role.Role_Name)); }