public ActionResult Edit([Bind(Include = "Id,Naam,Postcode,Huisnummer,EMail,BoekingID")] Gast gast) { List <int> boekingid = new List <int>(); foreach (var b in db.GetAllBoekingen()) { boekingid.Add(b.Id); } //validate new boekingID if (!boekingid.Contains(gast.BoekingID)) { return(RedirectToAction("Edit", "Gasten", new { id = gast.Id, valid = false })); } //validate gast if (ModelState.IsValid) { db.EditGast(gast); return(RedirectToAction("Index")); } return(View(gast)); }