Personally I'm trying to do a login logic but in a way without using the other asp mvc 5 technologies
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Cadastro(Fornecedor fornecedo, int? id )
{
var acesso = db.Fornecedor.Any(m => m.Codigo == id);
if (acesso == false)
{
db.Fornecedor.Add(fornecedo);
db.SaveChanges();
return RedirectToAction("a");
}
if(acesso == true){
ViewData["erro"] = "Mensagem de Erro";
return View();
}
return View("z");
}
When I register with the same code it gives an error that already exists this code but when I see if it has some data of the id for null.