Validation ASP MVC 5

Asked

Viewed 17 times

1

public class HomeController : Controller
{
    private ProjetoFornecedorEntities db = new  ProjetoFornecedorEntities();
    // GET: Home
    public ActionResult Index(Fornecedor fornecedor)
    {

        return View(db.Fornecedor.ToList());
    }
    public ActionResult Create()
    {
        return View();
    }

    [HttpPost]
    public ActionResult Create(Fornecedor fornecedor )
    {

            if (ModelState.IsValid)
            {


                db.Fornecedor.Add(fornecedor);
                db.SaveChanges();
                return RedirectToAction("Index");

            }

        return View("Create");
    }


}

Guys I’m going crazy already, my doubt is how not to duplicate fields at registration time for example ,I have a Cpf and can not register the same Cpf and as returns on screen,I searched and found the Remote but could not apply.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.