Created
August 15, 2011 13:50
-
-
Save carlhoerberg/1146796 to your computer and use it in GitHub Desktop.
Optional validation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPost] | |
public ActionResult Create(int id, Projekt model) | |
{ | |
var p = db.Get<Projekt>(id); | |
if (p.Typ1Validering) | |
if (string.IsNullOrEmpty(model.Field)) | |
ModelState.AddModelError("Field", "Fältet får inte vara tomt"); | |
if (ModelState.IsValid) | |
{ | |
UpdateModel(p); | |
db.SubmitChanges(); | |
RedirectToAction("/Projekt/Details/"+p.Id); | |
} | |
return View(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment