How can i can create a validation where i can only create 1 user with that name
my code
is this
[HttpPost]
public ActionResult Create(Klant klant)
{
ModelState.AddModelError("Firma", "Firma already exists");
if (ModelState.IsValid)
{
db.Klanten.Add(klant);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(klant);
}
now can i create 0 users because i get always the error firma already exists with my addmodelerror
Put
after "if" and before return statement