Пример #1
0
        // Construtor.
        public EventoViewModel()
        {
            try
            {
                NovoEventoCommand           = new Command(NovoEvento);
                ExcluirEventoCommand        = new Command(ExcluirEvento);
                EditarEventoCommand         = new Command(EditarEvento);
                GravarEventoCommand         = new Command(GravarEvento);
                CancelarEdicaoEventoCommand = new Command(CancelarEdicaoEvento);
                SairCommand      = new Command(Sair);
                PesquisarCommand = new Command(Pesquisar);

                // Cria o DAO.
                dao = DaoFactory.CreateDao <EventoDao>();

                IsEditing     = false;
                SelectedIndex = -1;

                // Obtém a lista inicial de eventos.
                Eventos = dao.ListarEventos(null);
            }
            catch (Exception e)
            {
                // Este catch é necessário para evitar erro no processo de criação do XAML.
                Debug.WriteLine("Erro: " + e.Message);
            }
        }
Пример #2
0
        public void SendEmailWhenRegisters(Participante participante)
        {
            var         eventoDao = new EventoDao();
            var         evento    = eventoDao.GetById(participante.IdEvento);
            MailMessage mail      = new MailMessage();

            mail.To.Add(new MailAddress(participante.Email));
            mail.From       = new MailAddress("*****@*****.**");
            mail.Subject    = "Cadastro no evento " + evento.Nome;
            mail.IsBodyHtml = true;
            mail.Body       = "" + participante.Nome + ",</br> Seu cadastro para o evento " + evento.Nome + " foi concluido com sucesso !";

            SmtpClient client = new SmtpClient("smtp-mail.outlook.com", 587);

            using (client)
            {
                client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "cedro123");
                client.EnableSsl   = true;
                try
                {
                    client.Send(mail);
                }
                catch (Exception ex)
                {
                    Console.Write("Não foi possivel enviar o email, Erro = " + ex.Message);
                }
            }
        }
Пример #3
0
        public string ListarEventos(int id_evento)
        {
            List <Evento> eventos;

            using (EventoDao dao = new EventoDao())
            {
                eventos = dao.BuscarEventos();
                if (eventos.Count > 0)
                {
                    PeriodoDao periodoDao = new PeriodoDao();
                    foreach (Evento evento in eventos)
                    {
                        evento.Periodos = periodoDao.ListarPorEvento(evento);
                    }
                }

                /*
                 * var serializer = new JsonSerializer
                 * {
                 *  ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
                 *  ContractResolver = new NHibernateContractResolver()
                 * };
                 * return NHibernateContractResolver.gerarJSON(eventos);
                 */
                return(JsonConvert.SerializeObject(eventos));
            }
        }
Пример #4
0
        public void LeaveEvento(int id)
        {
            var eventoDao = new EventoDao();
            var evento    = eventoDao.GetById(id);

            evento.IngressosVendidos--;
            eventoDao.Update(evento);
        }
Пример #5
0
        public void Delete(int id)
        {
            var eventoDao = new EventoDao();
            var emailBll  = new EmailBll();

            emailBll.SendMailWhenEventoDelete(id);
            eventoDao.Delete(id);
        }
Пример #6
0
        public void Create(EventoModelView eventoModelView)
        {
            var evento = new Evento();

            evento = PrepareEvento(eventoModelView, evento);
            var eventoDao = new EventoDao();

            eventoDao.Create(evento);
        }
Пример #7
0
        public void Update(int id, EventoModelView eventoModelView)
        {
            var eventoDao = new EventoDao();
            var evento    = eventoDao.GetById(id);

            evento = PrepareEvento(eventoModelView, evento);
            var emailBll = new EmailBll();

            emailBll.SendMailWhenEventoUpdate(evento);
            eventoDao.Update(evento);
        }
Пример #8
0
 public bool Inserir([FromUri] Evento evento)
 {
     using (EventoDao dao = new EventoDao())
     {
         try
         {
             dao.Inserir(evento);
             return(true);
         }catch (Exception e)
         {
             return(false);
         }
     }
 }
        public bool EventoExist(int id)
        {
            var eventoDao = new EventoDao();
            var evento    = eventoDao.GetById(id);

            if (evento != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #10
0
        public bool HaveIngresso(int id)
        {
            var eventoDao = new EventoDao();
            var evento    = eventoDao.GetById(id);

            if (evento.IngressosVendidos < evento.MaximoIngressos)
            {
                evento.IngressosVendidos++;
                eventoDao.Update(evento);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #11
0
        public string SaveEventoDao(EventoDao e)
        {
            ArgumentsValidator.RaiseExceptionOfInvalidArguments(
                RaiseException.IfNullOrEmpty(e.Titulo, "Título não informado"),
                RaiseException.IfNullOrEmpty(e.Descricao, "Descrição não informada"),
                RaiseException.IfTrue(DateTime.Equals(e.DtInicio, DateTime.MinValue), "Data de Início não informada"),
                RaiseException.IfTrue(DateTime.Equals(e.DtTermino, DateTime.MinValue), "Data de Término não informada"),
                RaiseException.IfNullOrEmpty(e.TipoEvento, "Tipo de Evento não informado")
                );

            EventoDao _e = new EventoDao()
            {
                EventoId           = e.EventoId,
                Titulo             = Functions.AjustaTamanhoString(e.Titulo, 100),
                Descricao          = Functions.AjustaTamanhoString(e.Descricao, 2000),
                Codigo             = Functions.AjustaTamanhoString(e.Codigo, 60),
                DtInicio           = e.DtInicio,
                DtTermino          = e.DtTermino,
                DtTerminoInscricao = e.DtTerminoInscricao,
                TipoEvento         = e.TipoEvento,
                AceitaIsencaoAta   = e.AceitaIsencaoAta,
                NomeFoto           = e.NomeFoto,
                Ativo = e.Ativo,
                TiposPublicosValoresDao = e.TiposPublicosValoresDao
            };

            try
            {
                if (_e.EventoId == 0)
                {
                    return(_eventoService.InsertEventoDao(_e));
                }
                else
                {
                    return(_eventoService.UpdateEventoDao(e.EventoId, _e));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #12
0
        public EventoDao GetEventoDaoById(int id)
        {
            query = @"SELECT EventoId, Titulo, Descricao, Codigo, DtInicio, DtTermino, 
                        DtTerminoInscricao, TipoEvento, AceitaIsencaoAta, Ativo, NomeFoto 
                    FROM dbo.AD_Evento 
                    WHERE EventoId = " + id + "";

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

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

            if (eventoDao != null)
            {
                TipoPublicoRepository tp = new TipoPublicoRepository();

                eventoDao.TiposPublicosValoresDao = tp.GetTipoPublicoValorByEventoId(eventoDao.EventoId);
            }

            return(eventoDao);
        }
Пример #13
0
        public Task <HttpResponseMessage> PostDao(EventoDao eventoDao)
        {
            HttpResponseMessage response = new HttpResponseMessage();
            var    tsc       = new TaskCompletionSource <HttpResponseMessage>();
            string resultado = "false";

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

                resultado = _eventoApplication.SaveEventoDao(eventoDao);

                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);
            }
        }
Пример #14
0
        public void SendMailWhenEventoDelete(int id)
        {
            var eventoBll         = new EventoDao();
            var evento            = eventoBll.GetById(id);
            var participanteBll   = new ParticipanteBll();
            var listParticipantes = participanteBll.GetParticipantes();

            foreach (var participante in listParticipantes)
            {
                if (participante.IdEvento != evento.IdEvento)
                {
                    continue;
                }
                MailMessage mail = new MailMessage();
                mail.To.Add(new MailAddress(participante.Email));
                mail.From       = new MailAddress("*****@*****.**");
                mail.Subject    = "Alterações no evento  " + evento.Nome;
                mail.IsBodyHtml = true;
                mail.Body       = "" + participante.Nome + ",<br/> Seu evento " + evento.Nome + " foi cancelado, entre em contato para mais detalhes";

                SmtpClient client = new SmtpClient("smtp-mail.outlook.com", 587);
                using (client)
                {
                    client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "cedro123");
                    client.EnableSsl   = true;
                    try
                    {
                        client.Send(mail);
                    }
                    catch (Exception ex)
                    {
                        Console.Write("Não foi possivel enviar o email, Erro = " + ex.Message);
                    }
                }
            }
        }
Пример #15
0
 public FuncionarioNeg()
 {
     funcionarioDao = new FuncionarioDao();
     eventoDao      = new EventoDao();
     convidadoDao   = new ConvidadoDao();
 }
Пример #16
0
 public EventoNeg()
 {
     objEventoDao = new EventoDao();
 }
Пример #17
0
        public List <Evento> GetEventos()
        {
            var eventoDao = new EventoDao();

            return(eventoDao.GetEventos());
        }
Пример #18
0
 public EventoNeg()
 {
     eventoDao      = new EventoDao();
     funcionarioDao = new FuncionarioDao();
 }
Пример #19
0
        public Evento GetById(int id)
        {
            var eventoDao = new EventoDao();

            return(eventoDao.GetById(id));
        }
Пример #20
0
        public string UpdateEventoDao(int id, EventoDao eventoDao)
        {
            bool   _resultado = false;
            string _msg       = "";

            using (SqlConnection connection = new SqlConnection(strConnSql))
            {
                connection.Open();

                SqlCommand     command = connection.CreateCommand();
                SqlTransaction transaction;

                // Start a local transaction.
                transaction = connection.BeginTransaction("AtualizarEvento");

                command.Connection  = connection;
                command.Transaction = transaction;

                try
                {
                    // Atualizando os dados na tabela PESSOA:
                    string _dtTermInscr = eventoDao.DtTerminoInscricao != null ? ", DtTerminoInscricao = @DtTerminoInscricao " : "";

                    command.CommandText = "" +
                                          "UPDATE dbo.AD_Evento " +
                                          "SET Titulo = @Titulo, Descricao = @Descricao, Codigo = @Codigo, " +
                                          "DtInicio = @DtInicio, DtTermino = @DtTermino, TipoEvento = @TipoEvento, " +
                                          "AceitaIsencaoAta = @AceitaIsencaoAta, NomeFoto = @NomeFoto, Ativo = @Ativo " + _dtTermInscr +
                                          "WHERE EventoId = @id";

                    command.Parameters.AddWithValue("Titulo", eventoDao.Titulo);
                    command.Parameters.AddWithValue("Descricao", eventoDao.Descricao);
                    command.Parameters.AddWithValue("Codigo", eventoDao.Codigo);
                    command.Parameters.AddWithValue("DtInicio", eventoDao.DtInicio);
                    command.Parameters.AddWithValue("DtTermino", eventoDao.DtTermino);
                    command.Parameters.AddWithValue("TipoEvento", eventoDao.TipoEvento);
                    command.Parameters.AddWithValue("AceitaIsencaoAta", eventoDao.AceitaIsencaoAta);
                    command.Parameters.AddWithValue("NomeFoto", eventoDao.NomeFoto);
                    command.Parameters.AddWithValue("Ativo", eventoDao.Ativo);
                    command.Parameters.AddWithValue("id", id);

                    if (_dtTermInscr != "")
                    {
                        command.Parameters.AddWithValue("DtTerminoInscricao", eventoDao.DtTerminoInscricao);
                    }

                    int i = command.ExecuteNonQuery();
                    _resultado = i > 0;

                    _msg = _resultado ? "Atualização realizada com sucesso" : "Atualização NÃO realizada com sucesso";

                    transaction.Commit();

                    // Atualizando os valores na tabela
                    List <string> lstResultados = new List <string>();

                    if (eventoDao.TiposPublicosValoresDao != null && i > 0)
                    {
                        foreach (var valor in eventoDao.TiposPublicosValoresDao)
                        {
                            lstResultados.Add(this.UpdateValorEvento(valor.ValorEventoPublicoId, valor));
                        }
                    }
                }
                catch (Exception ex)
                {
                    try
                    {
                        transaction.Rollback();
                    }
                    catch (Exception ex2)
                    {
                        throw new Exception($"Rollback Exception Type:{ex2.GetType()}. Erro:{ex2.Message}");
                    }
                    throw new Exception($"Commit Exception Type:{ex.GetType()}. Erro:{ex.Message}");
                }
                finally
                {
                    connection.Close();
                }
            }
            return(_msg);
        }
Пример #21
0
        public string InsertEventoDao(EventoDao eventoDao)
        {
            bool   _resultado = false;
            string _msg       = "";
            Int32  id         = 0;
            string _ident     = "";

            using (SqlConnection connection = new SqlConnection(strConnSql))
            {
                connection.Open();

                SqlCommand     command = connection.CreateCommand();
                SqlTransaction transaction;

                // Start a local transaction.
                transaction = connection.BeginTransaction("IncluirEvento");

                command.Connection  = connection;
                command.Transaction = transaction;

                try
                {
                    // Inserindo os dados na tabela:
                    string _dtTermInscr      = eventoDao.DtTerminoInscricao != null ? ", DtTerminoInscricao " : "";
                    string _paramDtTermInscr = eventoDao.DtTerminoInscricao != null ? ", @DtTerminoInscricao " : "";

                    command.CommandText = "" +
                                          "INSERT into dbo.AD_Evento (Titulo, Descricao, Codigo, DtInicio, DtTermino, " +
                                          "   TipoEvento, AceitaIsencaoAta, NomeFoto, Ativo " + _dtTermInscr + ") " +
                                          "VALUES(@Titulo, @Descricao, @Codigo, @DtInicio, @DtTermino, " +
                                          "   @TipoEvento, @AceitaIsencaoAta, @NomeFoto, @Ativo " + _paramDtTermInscr + ") " +
                                          "SELECT CAST(scope_identity() AS int) ";

                    command.Parameters.AddWithValue("Titulo", eventoDao.Titulo);
                    command.Parameters.AddWithValue("Descricao", eventoDao.Descricao);
                    command.Parameters.AddWithValue("Codigo", eventoDao.Codigo);
                    command.Parameters.AddWithValue("DtInicio", eventoDao.DtInicio);
                    command.Parameters.AddWithValue("DtTermino", eventoDao.DtTermino);
                    command.Parameters.AddWithValue("TipoEvento", eventoDao.TipoEvento);
                    command.Parameters.AddWithValue("AceitaIsencaoAta", eventoDao.AceitaIsencaoAta);
                    command.Parameters.AddWithValue("NomeFoto", eventoDao.NomeFoto);
                    command.Parameters.AddWithValue("Ativo", eventoDao.Ativo);

                    if (_dtTermInscr != "")
                    {
                        command.Parameters.AddWithValue("DtTerminoInscricao", eventoDao.DtTerminoInscricao);
                    }

                    id         = (Int32)command.ExecuteScalar();
                    _resultado = id > 0;

                    if (id > 0)
                    {
                        _ident = _ident.PadLeft(10 - id.ToString().Length, '0') + id.ToString();
                    }

                    _msg = id > 0 ? $"{_ident}Inclusão realizada com sucesso" : $"{_ident}Inclusão Não realizada com sucesso";

                    transaction.Commit();

                    // Inserindo os valores na tabela
                    List <string> lstResultados = new List <string>();

                    if (eventoDao.TiposPublicosValoresDao != null && id > 0)
                    {
                        foreach (var valor in eventoDao.TiposPublicosValoresDao)
                        {
                            valor.EventoId = id;
                            lstResultados.Add(this.InsertValorEvento(valor));
                        }
                    }
                }
                catch (Exception ex)
                {
                    // Attempt to roll back the transaction.
                    try
                    {
                        transaction.Rollback();
                    }
                    catch (Exception ex2)
                    {
                        throw new Exception($"Rollback Exception Type:{ex2.GetType()}. Erro:{ex2.Message}");
                    }
                    throw new Exception($"Commit Exception Type:{ex.GetType()}. Erro:{ex.Message}");
                }
                finally
                {
                    connection.Close();
                }
            }
            return(_msg);
        }
Пример #22
0
 public string InsertEventoDao(EventoDao eventoDao)
 {
     return(_eventoRepository.InsertEventoDao(eventoDao));
 }
Пример #23
0
 public string UpdateEventoDao(int id, EventoDao eventoDao)
 {
     return(_eventoRepository.UpdateEventoDao(id, eventoDao));
 }