public ActionResult Create(Item item) { // 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 { try { if (item.Observacao.Equals(string.Empty)) { } } catch (Exception) { string str = ""; item.Observacao = str; } if (ItemDAO.Create(item) != 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()); }
public async Task CreateItem(Item item) => await ItemDAO.Create(item);