Beispiel #1
0
        // GET: Home/Edit/5
        public ActionResult Edit(int id)
        {
            if (((Pessoas)Session["Logado"]) == null)
            {
                return(Redirect("~/Account/Login"));
            }

            Pessoas p = new NegociosControle().BuscarUsuario(id);

            if (p == null)
            {
                return(HttpNotFound());
            }

            return(View(p));
        }
Beispiel #2
0
        ///Listar Usuarios
        public ActionResult Listar()
        {
            Pessoas aux = (Pessoas)Session["Logado"];

            if (aux == null)
            {
                return(Redirect("~/Account/Login"));
            }
            if (aux.Nivel != 2)
            {
                return(Redirect("Index"));
            }

            var users = new NegociosControle().ListarUsuarios().OrderBy(u => u.Id);

            return(View(users.ToList()));
        }
Beispiel #3
0
        public ActionResult Edit([Bind(Include = "Id,Email,Nome,Login,Senha,Nivel")] Pessoas p)
        {
            try
            {
                p.Senha = Utils.GetHashSenha(p.Senha);
                bool alterou = new NegociosControle().AtualizarUsuario(p);

                if (alterou)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View(p));
                }
            }
            catch (Exception ex)
            {
                return(View(p));
            }
        }
Beispiel #4
0
        public ActionResult Delete(int id)
        {
            try
            {
                NegociosControle nc      = new NegociosControle();
                Pessoas          del     = nc.BuscarUsuario(id);
                bool             excluiu = nc.DeletarUsuario(del);

                if (excluiu)
                {
                    return(RedirectToAction("Listar"));
                }

                else
                {
                    return(View());
                }
            }
            catch (Exception ex)
            {
                return(View());
            }
        }