public ActionResult Deletar(int id = 0)
        {
            var model = new ShowRoomModelo.model.cadastros.ShowRoom();

            if (id > 0)
            {
                model = DAL.GetObjeto <ShowRoomModelo.model.cadastros.ShowRoom>(string.Format("id_conta={0} and id={1}", UsuarioLogado.IdConta, id));
                DAL.Excluir(model);
            }
            return(RedirectToAction("Consultar"));
        }
 public ActionResult Cadastrar(int id = 0)
 {
     if (Settings.hasPermission(Settings.MENU_CADASTRO_SHOWROOM, UsuarioLogado))
     {
         var model = new ShowRoomModelo.model.cadastros.ShowRoom();
         if (id > 0)
         {
             model = DAL.GetObjetoById <ShowRoomModelo.model.cadastros.ShowRoom>(id);
         }
         return(View(model));
     }
     else
     {
         return(View("~/views/Shared/error.cshtml"));
     }
 }
        public ActionResult Cadastrar(ShowRoomModelo.model.cadastros.ShowRoom model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            model.fantasia   = model.fantasia.ToUpper();
            model.razao      = model.razao.ToUpper();
            model.id_usuario = Convert.ToInt64(UsuarioLogado.IdUsuario);
            model.id_conta   = Convert.ToInt64(UsuarioLogado.IdConta);
            try
            {
                var existe = DAL.GetObjeto <ShowRoomModelo.model.cadastros.ShowRoom>(string.Format("id_conta={0} and showroom='{1}'", UsuarioLogado.IdConta, model.showroom)) ?? new ShowRoomModelo.model.cadastros.ShowRoom();
                if (existe.id > 0 && model.id == 0)
                {
                    this.AddNotification("Show Room já existe!", "Alerta");
                    return(View());
                }
                long id = DAL.Gravar(model);

                if (model.id > 0 && id == 0)
                {
                    this.AddNotification("Show Room alterada!", "Sucesso");
                }
                else
                {
                    this.AddNotification("Show Room cadastrada!", "Sucesso");
                }
            }
            catch (Exception e)
            {
                this.AddNotification("Erro:" + e.Message, "Erro");
            }
            return(View(model));
        }