Example #1
0
        public ActionResult List()
        {
            // Início: Proteção de rota
            if (Session["usuario_nivel"] == null)
            {
                TempData["msg"]      = "Necessário estar logado!";
                TempData["msg_type"] = "warning";
                return(RedirectToAction("Index", "Home"));
            }

            if (Convert.ToInt32(Session["usuario_nivel"]) > 1)
            {
                TempData["msg"]      = "Você não tem autorização para acessar esta área!";
                TempData["msg_type"] = "danger";
                return(RedirectToAction("Index", "Home"));
            }
            // Fim: Proteção de Rota

            try
            {
                LocalidadeCategoriaDAO.AtualizaCategorias();
                return(View(LocalidadeDAO.GetAll()));
            }
            catch
            {
            }
            return(RedirectToAction("Index", "Home"));
        }
Example #2
0
        public ActionResult Edit(int id)
        {
            // Início: Proteção de rota
            if (Session["usuario_nivel"] == null)
            {
                TempData["msg"]      = "Necessário estar logado!";
                TempData["msg_type"] = "warning";
                return(RedirectToAction("Index", "Home"));
            }

            if (Convert.ToInt32(Session["usuario_nivel"]) > 1)
            {
                TempData["msg"]      = "Você não tem autorização para acessar esta área!";
                TempData["msg_type"] = "danger";
                return(RedirectToAction("Index", "Home"));
            }
            // Fim: Proteção de Rota

            try
            {
                LocalidadeCategoriaDAO.AtualizaCategorias();
                Localidade local = LocalidadeDAO.GetByID(id);
                if (local != null)
                {
                    return(View(local));
                }
            }
            catch
            {
            }
            TempData["msg"]      = "Erro ao criar!";
            TempData["msg_type"] = "danger";
            return(RedirectToAction("Index"));
        }
        public ActionResult Create(LocalidadeCategoria cat)
        {
            // Início: Proteção de rota
            if (Session["usuario_nivel"] == null)
            {
                TempData["msg"]      = "Necessário estar logado!";
                TempData["msg_type"] = "warning";
                return(RedirectToAction("Index", "Home"));
            }

            if (Convert.ToInt32(Session["usuario_nivel"]) > 1)
            {
                TempData["msg"]      = "Você não tem autorização para acessar esta área!";
                TempData["msg_type"] = "danger";
                return(RedirectToAction("Index", "Home"));
            }
            // Fim: Proteção de Rota

            try
            {
                if (LocalidadeCategoriaDAO.Create(cat) != null)
                {
                    TempData["msg"] = "Criado com sucesso!";
                }
                TempData["msg_type"] = "success";
                return(RedirectToAction("Index"));
            }
            catch
            {
            }
            TempData["msg"]      = "Erro ao criar!";
            TempData["msg_type"] = "danger";
            return(View());
        }
 // GET: Relatorio
 public ActionResult Index()
 {
     LocalidadeDAO.AtualizaLocalidades();
     ItemCategoriaDAO.AtualizaCategorias();
     ItemStatusDAO.AtualizaTiposStatus();
     LocalidadeCategoriaDAO.AtualizaCategorias();
     return(View());
 }
 public ActionResult Create()
 {
     LocalidadeCategoriaDAO.AtualizaCategorias();
     return(View());
 }