Beispiel #1
0
        public ActionResult Delete()
        {
            // 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"]) > 0)
            {
                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

            int id = Convert.ToInt32(Request["inventario_id"]);

            if (InventarioDAO.Delete(id))
            {
                TempData["msg"]      = "Excluído com sucesso!";
                TempData["msg_type"] = "success";
                return(RedirectToAction("Inventario", "Inventario"));
            }
            TempData["msg"]      = "Ocorreu um erro!";
            TempData["msg_type"] = "danger";
            return(RedirectToAction("Inventario", "Inventario"));
        }