public ActionResult Edit(Estado model) { if (ModelState.IsValid) { model.nome = model.nome.ToUpper(); model.sigla = model.sigla.ToUpper(); model.ConfigurarParaSalvar(); db.Entry(model).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Paises = new SelectList(db.Pais, "Id", "Nome", "Sigla"); return(View(model)); }
public ActionResult Create(Estado model) { if (ModelState.IsValid) { model.nome = model.nome.ToUpper(); model.sigla = model.sigla.ToUpper(); if (VerificaJaExiste(model)) { ViewBag.Erro = "Ja existe um registro com os valores informados!"; return(View(model)); } model.ConfigurarParaSalvar(); db.Estado.Add(model); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Paises = new SelectList(db.Pais, "Id", "Nome", "Sigla"); return(View(model)); }