To solve this optimization problem, we first need to define the decision variables, the objective function, and the constraints.

Let's denote:
- \(x\) as the number of dining tables made,
- \(y\) as the number of bed frames made.

The objective is to maximize profit. Given that each dining table yields a profit of $300 and each bed frame yields a profit of $400, the objective function can be written as:
\[ \text{Maximize:} \quad 300x + 400y \]

The constraints are based on the availability of oak and mahogany wood:
- Each dining table requires 3 units of oak wood, and each bed frame requires 5 units of oak wood. The total oak wood available is 300 units. Therefore, the oak wood constraint is:
\[ 3x + 5y \leq 300 \]
- Each dining table requires 5 units of mahogany wood, and each bed frame requires 2 units of mahogany wood. The total mahogany wood available is 400 units. Therefore, the mahogany wood constraint is:
\[ 5x + 2y \leq 400 \]

Additionally, \(x\) and \(y\) must be non-negative since they represent quantities of products.

Now, let's translate this into Gurobi code in Python:

```python
from gurobipy import *

# Create a model
m = Model("Woodshop_Optimization")

# Define the decision variables
x = m.addVar(vtype=GRB.CONTINUOUS, name="dining_tables")
y = m.addVar(vtype=GRB.CONTINUOUS, name="bed_frames")

# Set the objective function
m.setObjective(300*x + 400*y, GRB.MAXIMIZE)

# Add constraints
m.addConstr(3*x + 5*y <= 300, "oak_wood_constraint")
m.addConstr(5*x + 2*y <= 400, "mahogany_wood_constraint")

# Optimize the model
m.optimize()

# Print the results
if m.status == GRB.OPTIMAL:
    print("Optimal solution found:")
    print(f"Dining tables: {x.x}")
    print(f"Bed frames: {y.x}")
    print(f"Maximum profit: {m.objVal}")
else:
    print("No optimal solution found")

```