I would like to strip out non-numeric elements from the POST data before using UpdateModel
to update the copy in the database. Is there a way to do this?
// TODO: it appears I don't even use the parameter given at all, and all the magic
// happens via UpdateModel and the "controller's current value provider"?
[HttpPost]
public ActionResult Index([Bind(Include="X1, X2")] Team model) // TODO: stupid magic strings
{
if (this.ModelState.IsValid)
{
TeamContainer context = new TeamContainer();
Team thisTeam = context.Teams.Single(t => t.TeamId == this.CurrentTeamId);
// TODO HERE: apply StripWhitespace() to the data before using UpdateModel.
// The data is currently somewhere in the "current value provider"?
this.UpdateModel(thisTeam);
context.SaveChanges();
this.RedirectToAction(c => c.Index());
}
else
{
this.ModelState.AddModelError("", "Please enter two valid Xs.");
}
// If we got this far, something failed; redisplay the form.
return this.View(model);
}
Sorry for the terseness, up all night working on this; hopefully my question is clear enough? Also sorry since this is kind of a newbie question that I might be able to get with a few hours of documentation-trawling, but I'm time-pressured... bleh.