Exemplo n.º 1
0
        public Estipulante Salvar(Estipulante estipulante)
        {
            using (ISession sessao = ObterSessao())
            {
                using (ITransaction tran = sessao.BeginTransaction())
                {
                    sessao.SaveOrUpdate(estipulante);
                    tran.Commit();
                }
            }

            return(estipulante);
        }
Exemplo n.º 2
0
        protected void cmdSalvar_Click(object sender, EventArgs e)
        {
            #region validacoes

            if (txtNome.Text.Trim().Length == 0)
            {
                Geral.Alerta(this, "Informe o nome do estipulante.");
                return;
            }

            #endregion

            Estipulante estipulante = new Estipulante();
            estipulante.ContratanteId = UsuarioLogado.IDContratante;

            if (!string.IsNullOrEmpty(Request[Keys.rKey]))
            {
                long id = Geral.ProcessaQueryStringSegura <long>(Request[Keys.rKey], Keys.IdKey);
                estipulante = EstipulanteFacade.Instancia.Carregar(id, UsuarioLogado.IDContratante);

                if (estipulante == null)
                {
                    throw new ApplicationException("Security exception.");
                }
            }

            estipulante.Ativo = chkAtivo.Checked;

            if (estipulante.TemId)
            {
                estipulante.DataAlteracao = DateTime.Now;
            }
            else
            {
                estipulante.DataCadastro = DateTime.Now;
            }

            estipulante.Nome = txtNome.Text;

            EstipulanteFacade.Instancia.Salvar(estipulante);
            Response.Redirect("estipulantes.aspx");
        }
Exemplo n.º 3
0
        public Estipulante Carregar(long id, long?contratanteId = null)
        {
            Estipulante ret = null;

            using (ISession sessao = ObterSessao())
            {
                if (!contratanteId.HasValue || contratanteId.Value == 0)
                {
                    ret = sessao.Query <Estipulante>()
                          .Where(c => c.ID == id).SingleOrDefault();
                }
                else
                {
                    ret = sessao.Query <Estipulante>()
                          .Where(c => c.ID == id && c.ContratanteId == contratanteId.Value).SingleOrDefault();
                }
            }

            return(ret);
        }