public string Save(AssinaturaEventoDao a)
        {
            AssinaturaEvento assinaturaEvento = new AssinaturaEvento
            {
                AssinaturaEventoId   = a.AssinaturaEventoId,
                AssociadoId          = a.AssociadoId,
                ValorEventoPublicoId = a.ValorEventoPublicoId,
                PercentualDesconto   = a.PercentualDesconto,
                TipoDesconto         = a.TipoDesconto,
                DtAssinatura         = a.DtAssinatura,
                DtAtualizacao        = a.DtAtualizacao,
                Ativo = a.Ativo
            };

            try
            {
                if (assinaturaEvento.AssinaturaEventoId == 0)
                {
                    return(_assinaturaEventoService.Insert(assinaturaEvento));
                }
                else
                {
                    return(_assinaturaEventoService.Update(assinaturaEvento.AssinaturaEventoId, assinaturaEvento));
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
        public AssinaturaEventoDao GetAssinaturaEventoById(int id)
        {
            query = @"SELECT AE.AssinaturaEventoId, AE.AssociadoId, AE.ValorEventoPublicoId, AE.PercentualDesconto, 
                        AE.TipoDesconto, AE.DtAssinatura, AE.DtAtualizacao, AE.Ativo, P.Nome as NomePessoa, 
                        P.CPF, TP.Nome as NomeTP, E.Titulo, VEP.Valor 
                    FROM dbo.AD_Assinatura_Evento AE 
                        INNER JOIN dbo.AD_Valor_Evento_Publico VEP ON AE.ValorEventoPublicoId  = VEP.ValorEventoPublicoId  
                        INNER JOIN dbo.AD_Evento E ON VEP.EventoId = E.EventoId 
                        INNER JOIN dbo.AD_Associado ASO ON AE.AssociadoId = ASO.AssociadoId 
                        INNER JOIN dbo.AD_Pessoa P ON ASO.PessoaId = P.PessoaId 
                        INNER JOIN dbo.AD_Tipo_Publico TP ON VEP.TipoPublicoId = TP.TipoPublicoId
                    WHERE AE.AssinaturaEventoId > " + id + " ORDER BY AE.AssociadoId, AE.AssinaturaEventoId ";

            // Define o banco de dados que será usando:
            CommandSql cmd = new CommandSql(strConnSql, query, EnumDatabaseType.SqlServer);

            // Obtém os dados do banco de dados:
            AssinaturaEventoDao assinaturaAssociadoDao = GetCollection <AssinaturaEventoDao>(cmd)?.FirstOrDefault <AssinaturaEventoDao>();

            // Log da consulta:
            string log = logRep.SetLogger(className + "/GetAssinaturaEventoById",
                                          "SELECT", "ASSINATURA_EVENTO", id, query, assinaturaAssociadoDao != null ? "SUCESSO" : "0");

            // Fim Log

            return(assinaturaAssociadoDao);
        }
Exemple #3
0
        public Task <HttpResponseMessage> Post(AssinaturaEventoDao assinaturaEventoDao)
        {
            HttpResponseMessage response = new HttpResponseMessage();
            var    tsc       = new TaskCompletionSource <HttpResponseMessage>();
            string resultado = "false";

            try
            {
                if (assinaturaEventoDao == null)
                {
                    throw new ArgumentNullException("O objeto 'assinaturaEventoDao' está nulo!");
                }

                resultado = _assinaturaEventoApplication.Save(assinaturaEventoDao);

                response = Request.CreateResponse(HttpStatusCode.OK, resultado);
                response.ReasonPhrase = resultado;

                tsc.SetResult(response);

                return(tsc.Task);
            }
            catch (Exception ex)
            {
                if (ex.GetType().Name == "InvalidOperationException" || ex.Source == "prmToolkit.Validation")
                {
                    response = Request.CreateResponse(HttpStatusCode.NotFound);
                    response.ReasonPhrase = ex.Message;
                }
                else
                {
                    response = Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
                }
                tsc.SetResult(response);

                return(tsc.Task);
            }
        }