-1
2個表單和2個控制器動作具有幾乎相同的代碼或者在模型中創建新屬性以確定控制器中應發生什麼更好?在mvc模型中幾乎具有相同功能或參數的2個表單和2個後處理動作
public ActionResult SubmitFactors(EntityRelationshipsIndexModel m)
{
Method1();
Method2();
if (m.Factor.Equals("X"))
{
m.Yfactor = null;
}
else
{
m.XFactor = null;
}
Method3();
}
OR
public ActionResult SubmitXFactor(EntityRelationshipsIndexModel m)
{
Method1();
Method2();
model.Y = null;
Method3();
}
public ActionResult SubmitYFactor(EntityRelationshipsIndexModel m)
{
Method1();
Method2();
model.X = null;
Method3();
}