示例#1
0
文件: Venda.cs 项目: icaroferj/ir-api
        private static void TratarEnvioNPS(Cliente oCliente)
        {
            bool desabilitar = Convert.ToBoolean(ConfigurationManager.AppSettings["desabilitarNPS"]);

            if (!desabilitar)
            {
                int    delay    = Convert.ToInt32(ConfigurationManager.AppSettings["delayNPS"]);
                string canalNPS = Convert.ToString(ConfigurationManager.AppSettings["canalNPS"]);

                try
                {
                    using (var bo = new NetPromoterServiceBO())
                    {
                        bo.SendDataNPS(oCliente.Nome.Valor, oCliente.Email.Valor, delay, canalNPS);
                    }
                }
                catch (Exception)
                {
                    using (var bo = new NetPromoterServiceBO())
                    {
                        bo.AdicionarAgendamento(oCliente.Nome.Valor, oCliente.Email.Valor, delay, canalNPS);
                    }
                }
            }
        }
示例#2
0
        public RetornoModel AtualizarAgendamentoRange([FromBody] NpsAtualizarAgendamentoRange rq)
        {
            RetornoModel ret = new RetornoModel();

            ret.Mensagem = "OK";
            ret.Sucesso  = true;

            if (rq == null)
            {
                ret.Mensagem = "Erro ao obter os dados para realizar o agendamento";
                ret.Sucesso  = false;
                return(ret);
            }

            if (rq.IdAgendamentoInicial < 0 || rq.IdAgendamentoFinal < 0) // Se IdAgendamentoInicial e IdAgendamentoFinal for menor que zero, então...
            {
                ret.Mensagem = "IdAgendamentoInicial/IdAgendamentoFinal não foi encontrado";
                ret.Sucesso  = false;
                return(ret);
            }

            if (rq.IdAgendamentoFinal > rq.IdAgendamentoInicial) // Testa se final não é maior que o inicial
            {
                ret.Mensagem = "IdAgendamentoFinal não pode ser maior que IdAgendamentoInicial";
                ret.Sucesso  = false;
                return(ret);
            }

            try
            {
                // Atualizar o status do agendamento
                using (var bo = new NetPromoterServiceBO())
                {
                    DateTime?DataEnvio = null;
                    if (rq.Status == enumStatusNPS.Sucesso) // Se status for de sucesso, atualizo a data que foi realizado o envio dos dados
                    {
                        DataEnvio = DateTime.Now;
                    }

                    bo.AtualizarAgendamentoRange(Convert.ToString(rq.IdAgendamentoInicial), Convert.ToString(rq.IdAgendamentoFinal), rq.Status.ValueAsString(), DataEnvio);
                }
            }
            catch (Exception ex)
            {
                ret.Mensagem = ex.Message;
                ret.Sucesso  = false;
            }

            return(ret);
        }
示例#3
0
        public RetornoModel AdicionarAgendamento([FromBody] NpsAdicionarAgendamentoModel rq)
        {
            RetornoModel ret = new RetornoModel();

            ret.Mensagem = "OK";
            ret.Sucesso  = true;
            try
            {
                using (var bo = new NetPromoterServiceBO())
                {
                    bo.AdicionarAgendamento(rq.Name, rq.Email, rq.Delay, rq.Canal);
                }
            }
            catch (Exception ex)
            {
                ret.Mensagem = ex.Message;
                ret.Sucesso  = false;
            }

            return(ret);
        }
示例#4
0
        public RetornoModel <List <NpsModel> > ObterAgendamentosPorStatus(enumStatusNPS Status)
        {
            RetornoModel <List <NpsModel> > retorno = new RetornoModel <List <NpsModel> >();

            retorno.Mensagem = "OK";
            retorno.Sucesso  = true;
            retorno.Retorno  = new List <NpsModel>();

            try
            {
                using (var bo = new NetPromoterServiceBO())
                {
                    var registros = bo.ObterAgendamentosPorStatus(Status.ValueAsString()).ToList();
                    registros.ForEach(a =>
                    {
                        NpsModel nps     = new NpsModel();
                        nps.ID           = a.ID;
                        nps.Name         = a.Name;
                        nps.Email        = a.Email;
                        nps.Delay        = a.Delay;
                        nps.Status       = a.Status;
                        nps.Canal        = a.Canal;
                        nps.DataInclusao = a.DataInclusao;
                        nps.DataEnvio    = a.DataEnvio;

                        retorno.Retorno.Add(nps);
                    });
                }
            }
            catch (Exception ex)
            {
                retorno.Mensagem = ex.Message;
                retorno.Sucesso  = false;
            }

            return(retorno);
        }