Exemplo n.º 1
0
        // Pega os chamados e joga na tela
        public ActionResult Index(int pagina = 1)
        {
            UserInfo.UserInfo infouser = new UserInfo.UserInfo();
            string            usuario  = infouser.GetUserInfo(17);

            string[] info = usuario.Split('|');


            // CRIA VARIAVEL PARA PODER ACESSAR O NOME(TIPO DE USUARIO) PARA PODER CRIAR LISTA DE CHAMADOS
            var manager     = new UserManager <ApplicationUser>(new Microsoft.AspNet.Identity.EntityFramework.UserStore <ApplicationUser>(new ApplicationDbContext()));
            var currentUser = manager.FindById(User.Identity.GetUserId());

            //JOGA TODOS OS CHAMADOS PARA USUARIO MASTER
            if (currentUser.TipoUsuario == "MASTER")
            {
                var chamados = db.Chamados.Include(c => c.Categoria).Include(c => c.Status)
                               .Include(c => c.SubCategoria).Include(c => c.UsuarioRequisitante)
                               .Include(c => c.UsuarioResponsavel).Include(c => c.Equipamento).OrderByDescending(i => i.IdChamado).ToPagedList(pagina, 10);


                return(View(chamados));
            }
            //JOGA SÓ OS CHAMADOS DO USUARIO, CASO NÃO SEJA MASTER
            else
            {
                var chamados = db.Chamados.Include(c => c.Categoria).Include(c => c.Status)
                               .Include(c => c.SubCategoria).Include(c => c.UsuarioRequisitante)
                               .Include(c => c.UsuarioResponsavel).Include(c => c.Equipamento).Where(x => x.RequisitanteID == User.Identity.Name).OrderByDescending(i => i.IdChamado).ToPagedList(pagina, 10);

                return(View(chamados));
            }
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true

            wbLogin.Service1  servico  = new wbLogin.Service1();
            UserInfo.UserInfo infouser = new UserInfo.UserInfo();
            string            usuario  = infouser.GetUserInfo(Convert.ToInt32(model.Matricula));

            string[] info = usuario.Split('|');
            info[1] = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(info[1].ToLower());


            RegisterViewModel registrarUsuario = new RegisterViewModel()
            {
                Matricula       = model.Matricula,
                Password        = model.Password,
                ConfirmPassword = model.Password,
                Name            = info[1],
                TipoUsuario     = info[0]
            };

            if (servico.cVerificaSenha(model.Matricula, model.Password))
            {
                await Register(registrarUsuario);

                var result = await SignInManager.PasswordSignInAsync(model.Matricula, model.Password, model.RememberMe, shouldLockout : false);

                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                switch (result)
                {
                case SignInStatus.Success:
                    return(RedirectToLocal(returnUrl));

                case SignInStatus.LockedOut:
                    return(View("Lockout"));

                case SignInStatus.RequiresVerification:
                    return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }));

                case SignInStatus.Failure:
                default:
                    ModelState.AddModelError("", "Invalid login attempt.");
                    return(View(model));
                }
            }
            else
            {
                ModelState.AddModelError("", "Senha incorreta.");
                return(View(model));
            }
        }
Exemplo n.º 3
0
 public ViewUserInfo()
 {
     UserInfo = new UserInfo.UserInfo();
     User     = new UserSimp();
 }