4
I did that:
[HttpPost]
public void CadastraUsusario(string _nome, string _usuario, string _email, string _nivel_acesso, bool _ativo)
{
using (RupturaEntities db = new RupturaEntities())
{
Usuario usu = new Usuario();
try
{
var retorna_usuario = db.Usuario
.Where(u => u.NM_Usuario == _nome && u.Usuario1 == _usuario)
.Select(d => new { d.NM_Usuario, d.Usuario1 }).ToList();
if (retorna_usuario == null)
{
usu.NM_Usuario = _nome;
usu.Usuario1 = _usuario;
usu.Email = _email;
usu.NivelAcesso = _nivel_acesso;
usu.Ativo = _ativo;
db.Usuario.Add(usu);
db.SaveChanges();
}
else
{
ViewBag.MsgError = "Usuário já está cadastrado no sistema.";
}
}
catch (Exception ex)
{ }
}
}
How do I stop when my Inline returns something, I do not proceed with inserting and triggering the message on the user screen?
I haven’t been able to send a controller message to the view and display on the user page.
– pnet
Have you implemented all the steps? What about your code? You inspected the
<div id="flash">
when testing?– Leonel Sanches da Silva
See if that’s it. You created a view called Flash.cshtl. Then in the _Layout.cshtml view you made the appropriate changes. He created a class called Flashhelper.Cs and there inside the controller that in my case, will make the rule and the message, put the 3 lines (Use) that you believe. If that was it, could not make it work, I even tried to create exactly as you said, until the folders I have not created them to look exactly like you put here.
– pnet
You can update the question with the implemented code?
– Leonel Sanches da Silva