Ejemplo n.º 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
            {
                LocalidadeDAO.AtualizaLocalidades();
                ItemCategoriaDAO.AtualizaCategorias();
                ItemStatusDAO.AtualizaTiposStatus();
                List <Item> lista = ItemDAO.GetAll();
                TempData["lista_status"] = ItemStatusDAO.lista_status;
                return(View(lista));
            }
            catch
            {
                TempData["msg"]      = "Erro ao buscar dados!";
                TempData["msg_type"] = "danger";
                return(View());
            }
        }
        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();
                ItemCategoria cat = ItemCategoriaDAO.GetByID(id);
                if (cat != null)
                {
                    return(View(cat));
                }
            }
            catch
            {
            }
            TempData["msg"]      = "Erro ao buscar dados";
            TempData["msg_type"] = "danger";
            return(View());
        }
        public ActionResult Edit(ItemCategoria 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 (ItemCategoriaDAO.Update(cat))
                {
                    TempData["msg"]      = "Alterado com sucesso!";
                    TempData["msg_type"] = "success";
                    return(RedirectToAction("Index"));
                }
            }
            catch
            {
            }
            TempData["msg"]      = "Erro ao criar";
            TempData["msg_type"] = "danger";
            return(View());
        }
        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(ItemCategoriaDAO.GetAll()));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 5
0
 // GET: Relatorio
 public ActionResult Index()
 {
     LocalidadeDAO.AtualizaLocalidades();
     ItemCategoriaDAO.AtualizaCategorias();
     ItemStatusDAO.AtualizaTiposStatus();
     LocalidadeCategoriaDAO.AtualizaCategorias();
     return(View());
 }