Example #1
0
        public ActionResult GravarPasta(string Pasta, string PastaOld)
        {
            var form = (JObject)JsonConvert.DeserializeObject(Pasta);

            Pasta _anterior = new Pasta();
            Pasta _novo = new Pasta();

            _novo.PastaId = (int)Util.GetValue<int>(form, "PastaId");
            _novo.PastaPaiId = (int?)Util.GetValue<int?>(form, "PastaPaiId");
            _novo.SiteId = GetCurrentSite();
            _novo.Descricao = (string)Util.GetValue<string>(form, "Descricao");

            #region --> Validação
            PastaResponse resp = new PastaResponse();
            if (string.IsNullOrEmpty(_novo.Descricao) || string.IsNullOrWhiteSpace(_novo.Descricao))
            {
                resp.Resposta.Erro = true;
                resp.Resposta.Mensagem += "- Informar uma Descrição";
            }
            if (resp.Resposta.Erro)
            {
                return Json(resp, JsonRequestBehavior.AllowGet);
            }
            #endregion

            return Json(new PastaDAL().Gravar(_novo, _anterior), JsonRequestBehavior.AllowGet);
        }
Example #2
0
        public PastaResponse ExcluirPasta(int PastaId)
        {
            PastaResponse resposta = new PastaResponse();
            try
            {
                using (ConexaoDB objetoConexao = new ConexaoDB())
                {
                    objetoConexao.AdicionarParametro("@PastaId", SqlDbType.Int, PastaId);
                    using (DataTable dt = objetoConexao.RetornarTabela("USP_DEL_Pasta"))
                    {
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            resposta.Resposta.Erro = (bool)dt.Rows[0]["indErro"];
                            resposta.Resposta.Mensagem = (string)dt.Rows[0]["msgErro"];
                            resposta.Pasta = null;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                resposta.Resposta.Erro = true;
                resposta.Resposta.Mensagem = ex.Message;

                //logBLL.Error(ex);
            }
            return resposta;
        }
Example #3
0
        public PastaResponse Gravar(Pasta Pasta, Pasta PastaOld)
        {
            PastaResponse resposta = new PastaResponse();
            try
            {
                using (ConexaoDB objetoConexao = new ConexaoDB())
                {
                    objetoConexao.AdicionarParametro("@PastaId", SqlDbType.Int, Pasta.PastaId);
                    objetoConexao.AdicionarParametro("@PastaPaiId", SqlDbType.Int, Pasta.PastaPaiId);
                    objetoConexao.AdicionarParametro("@SiteId", SqlDbType.Int, Pasta.SiteId);
                    objetoConexao.AdicionarParametro("@Descricao", SqlDbType.VarChar, Pasta.Descricao);
                    using (DataTable dt = objetoConexao.RetornarTabela("USP_INS_Pasta"))
                    {
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            resposta.Resposta.Erro = false;
                            resposta.Resposta.Mensagem = "";
                            resposta.Pasta = Pasta;
                            resposta.Pasta.PastaId = (int)dt.Rows[0]["PastaId"];
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                resposta.Resposta.Erro = true;
                resposta.Resposta.Mensagem = ex.Message;
                //logBLL.Error(ex);
            }
            return resposta;
        }
Example #4
0
        public PastaResponse Carregar(int PastaId)
        {
            PastaResponse resposta = new PastaResponse();
            Pasta pasta;

            try
            {
                using (ConexaoDB objetoConexao = new ConexaoDB())
                {
                    objetoConexao.AdicionarParametro("@PastaId", SqlDbType.Int, PastaId);
                    objetoConexao.AdicionarParametro("@SiteId", SqlDbType.Int, DBNull.Value);
                    using (DataTable dt = objetoConexao.RetornarTabela("USP_SEL_Pasta"))
                    {
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            DataRow dr = dt.Rows[0];
                            pasta = new Pasta();
                            CarregarDTO_Pasta(pasta, dr);

                            resposta.Pasta = pasta;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //logBLL.Error(ex);
                throw;
            }

            return resposta;
        }