public static IHtmlString SiglaUsuario(this HtmlHelper helper, SCadastroUsuarioLogadoViewModel cadastro) { var nomes = cadastro.Pessoa.Nome.Split(' '); var sigla = nomes.First()[0].ToString() + nomes.Last()[0].ToString(); return(new MvcHtmlString(sigla)); }
public ActionResult Index(SCadastroUsuarioLogadoViewModel cadastro, string actn, string ctrl) { var sCadastro = _cadastroApp.BuscaUsuarioLoginSenha(cadastro.Login, cadastro.Senha); if (sCadastro != null) { if (Session["usuarioLogado"] == null) { var cadastroUsuarioLogado = Mapper.Map <SCadastro, SCadastroUsuarioLogadoViewModel>(sCadastro); cadastroUsuarioLogado.Papeis = buscaPapeis(sCadastro.Pessoa_Id); Session.Timeout = 10; Session.Add("usuarioLogado", cadastroUsuarioLogado); } if (sCadastro.AlterarSenha == true) { return(RedirectToAction("AlterarSenha", "SCadastros")); } if (actn != null && ctrl != null) { return(RedirectToAction(actn, ctrl)); } return(RedirectToAction("Index", "Home")); } ModelState.AddModelError(string.Empty, "Login ou Senha inválido"); return(View(cadastro)); }
public static IHtmlString NomeUsuario(this HtmlHelper helper, SCadastroUsuarioLogadoViewModel cadastro) { if (cadastro.Pessoa.Apelido == "") { return(new MvcHtmlString(cadastro.Pessoa.Nome)); } return(new MvcHtmlString(cadastro.Pessoa.Apelido)); }
public static IHtmlString PapeisUsuarioLogado(this HtmlHelper helper, SCadastroUsuarioLogadoViewModel cadastro) { var texto = ""; foreach (var papel in cadastro.Papeis) { if (texto != "") { texto += Environment.NewLine; } texto += $" <a class=\"nav-link dropdown-item\" style=\"color: black\">" + " <i class=\"fa fa-fw fas fa-asterisk\"></i>" + papel.Nome + " </a>"; } return(new MvcHtmlString(texto)); }