示例#1
0
        public ActionResult Confirmar(string [] confirmar, string cnf, int Id)
        {
            int    eventoId = Id;
            string msg      = "Seleccione pelo menos uma inscrição.";
            string type     = "danger";

            if (confirmar != null)
            {
                foreach (var epId in confirmar)
                {
                    int id     = int.Parse(epId);
                    var result = _eventoParticipanteRepository.ObterPorId(id);
                    eventoId = result.EventoId;
                    if (cnf != null)
                    {
                        result.Confirmado = true;
                        msg  = "confirmada.";
                        type = "success";
                    }
                    else
                    {
                        result.Confirmado = false;
                        msg = "cancelada.";
                    }

                    _eventoParticipanteRepository.Actualizar(result);

                    var eventoParticipante = _eventoParticipanteRepository.ObterPorEventoParticipante(result.EventoId, result.ParticipanteId);
                    if (eventoParticipante != null)
                    {
                        var message = new Message(new string[] { eventoParticipante.Participante.Email },
                                                  "Resultado de inscrição", $"Olá, {eventoParticipante.Participante.Nome}.<br><br> " +
                                                  $"Resultado de inscrição disponível para o evento: { eventoParticipante.Evento.Titulo}. <br> A sua inscrição foi { msg }.", null);
                        if (Notificar(message))
                        {
                            _alertaRepository.Adicionar(Alerta(result, "Resultado de inscrição disponível para o evento: ", true));
                        }
                    }
                }
            }

            return(RedirectToAction("Index", new { id = eventoId, msg = "Inscrição " + msg, type = type }));
        }
示例#2
0
 public EventoParticipante ObterPorId(int id)
 {
     return(_eventoParticipanteRepository.ObterPorId(id));
 }