The Following Is A Bad Idea
But do you see why?
If you don't, comment.
public ActionResult Update()
{
ViewModelC c = new ViewModelC();
if(TryUpdateModel(c, "A") && TryUpdateModel(c, "B"))
{
// do some kind of update
returnView("Result");
}
// Display errors
returnView("Add", c);
}
If you don't, comment.
Labels: bad idea challenge
2 Comments:
Because of TryUpdateModel "A" succeeds and "B" doesn't...
Close. If TryUpdateModel "A" fails, TryUpdateModel "B" will never even get executed, and your model will be incomplete, which will have Unexpected Consequences when you try to display it again.
Post a Comment
<< Home