예제 #1
0
        public ActionResult consultarInvitados(int idViaje)
        {
            IRepositorioParticipante<Participante> repoParti = new ParticipanteRepositorio();
            IRepositorioPersona<Persona> repoP = new PersonaRepositorio();
            IList<Participante> participantes = new List<Participante>();
            IList<Persona> personas = new List<Persona>();

            participantes = repoParti.GetAll();

            foreach (var item in participantes)
            {
                if (item.IdViaje == idViaje)
                {
                    personas.Add(repoP.GetById(item.Nickname));
                }
            }

            return View("VerAmigos", personas);
        }
예제 #2
0
        public ActionResult Pdf()
        {
            String idViaje = Session["idViajePdf"] as string;
            string urlToConvert = "http://localhost/MvcApplication1/Viaje/ViajeDestinosReporte?idViaje=" + idViaje;
            string downloadName = "Viaje";
            byte[] downloadBytes = null;
            downloadName += ".pdf";
            PdfConverter pdfConverter = GetPdfConverter();
            downloadBytes = pdfConverter.GetPdfBytesFromUrl(urlToConvert);

            if (Session["data"] != "")
            {
                using (
                    System.IO.Stream s =
                        System.IO.File.Create(@"c:\inetpub\wwwroot\Pdf\" + Session["data"] + "Viaje" + idViaje +
                                              ".pdf"))
                {
                    s.Write(downloadBytes, 0, downloadBytes.Length);
                }

            }
            IPHostEntry host;
            string localIP = "?";
            host = Dns.GetHostEntry(Dns.GetHostName());
            foreach (IPAddress ip in host.AddressList)
            {
                if (ip.AddressFamily == AddressFamily.InterNetwork)
                {
                    localIP = ip.ToString();
                }
            }

            string url = "http://" + localIP + "/Pdf/" + Session["data"] + "Viaje" + idViaje +".pdf";
            string urlCorto = Shorten(url);

            IRepositorioPersona<Persona> repoP = new PersonaRepositorio();
            IRepositorioParticipante<Participante> repoParti = new ParticipanteRepositorio();
            IList<Participante> participantes = new List<Participante>();
            IList<Participante> participantesV = new List<Participante>();

            participantes = repoParti.GetAll();

            foreach (var item in participantes)
            {
                if (item.IdViaje == Convert.ToInt32(idViaje))
                {
                    participantesV.Add(item);
                }
            }

            IList<Persona> perList = new List<Persona>();

            foreach (var item in participantesV)
            {
                perList.Add(repoP.GetById(item.Nickname));
            }

            System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
            foreach (var persona in perList)
            {
                msg.To.Add(persona.Email);
            }
            IRepositorio<Viaje> repov = new ViajeRepositorio();
            Viaje v = repov.GetById(Convert.ToInt32(idViaje));

            msg.From = new MailAddress("*****@*****.**", "Twisted", System.Text.Encoding.UTF8);
            msg.Subject = "Ha sido cerrado el Viaje " + v.Nombre;
            msg.SubjectEncoding = Encoding.UTF8;
            msg.Body = "Hola , \n\n El Viaje " + v.Nombre + " Ha Sido Cerrado.\n Este es el Url del PDF que Contine La hoja de Ruta "+urlCorto+".\nGracias!\n\nTe invitamos a Seguirnos @TwistedUCAB  \n\nSaludos, \nj2l Team © ";
            msg.BodyEncoding = Encoding.UTF8;
            msg.IsBodyHtml = false;
            String twt = "El viaje "+ v.Nombre +" Ha Sido Cerrado Este el itinerario " + urlCorto;

            Session["twt"] = twt;
            //Aquí es donde se hace lo especial
            SmtpClient client = new SmtpClient();
            client.Credentials = new NetworkCredential("*****@*****.**", "j2ltwisted");
            client.Port = 587;
            client.Host = "smtp.gmail.com";
            client.EnableSsl = true;
            try
            {
                client.Send(msg);
            }
            catch (System.Net.Mail.SmtpException ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadLine();
            }
            HttpResponse response = System.Web.HttpContext.Current.Response;

             /*   response.Clear();
            response.AddHeader("Content-Type", "binary/octet-stream");
            response.AddHeader("Content-Disposition",
                "attachment; filename=" + downloadName + "; size=" + downloadBytes.Length.ToString());
            response.BinaryWrite(downloadBytes);
            response.Flush();
            response.End();*/

            return RedirectToAction("CerrarViaje", "Twitter");
        }
예제 #3
0
        public ActionResult InvitarAmigos(int id)
        {
            string nick = Session["data"] as string;

            IRepositorio<Amistad> repo = new AmistadRepositorio();
            IRepositorioPersona<Persona> repoPer = new PersonaRepositorio();
            IList<Amistad> amistades = repo.GetAll();
            IList<Persona> amigos = new List<Persona>();

            foreach (var item in amistades)
            {
                if (item.Nickname == nick)
                {
                    amigos.Add(repoPer.GetById(item.NicknameAmigo));
                }
            }

            IRepositorioPersona<Persona> repoP = new PersonaRepositorio();
            IRepositorioParticipante<Participante> repoParti = new ParticipanteRepositorio();
            IList<Participante> participantes = new List<Participante>();
            IList<Participante> participantesV = new List<Participante>();
            IList<Persona> amigosNoInv = new List<Persona>();

            participantes = repoParti.GetAll();

            foreach (var item in participantes)
            {
                if (item.IdViaje == id)
                {
                    participantesV.Add(item);
                }
            }

            bool flag = false;
            foreach (var item in amigos)
            {
                foreach (var itemPar in participantesV)
                {
                    if (item.Nickname == itemPar.Nickname)
                    {
                        flag = true;
                    }
                }

                if (!flag)
                {
                  amigosNoInv.Add(repoP.GetById(item.Nickname));
                }
                flag = false;
            }
            Session["idViajeInvitado"] = id;
            return View(amigosNoInv);
        }
예제 #4
0
 public ActionResult InvitarAmigoViaje(string nick, int idViaje)
 {
     IRepositorioParticipante<Participante> repoP = new ParticipanteRepositorio();
     Participante miParticipante = new Participante();
     miParticipante.IdViaje = idViaje;
     miParticipante.Nickname = nick;
     miParticipante.Tipo = "Participante";
     repoP.Save(miParticipante);
     return RedirectToAction("InvitarAmigos", "Persona", new { id = idViaje });
 }
예제 #5
0
 public ActionResult ViajesPersona()
 {
     if (Request["nickname"] != null)
     {
         var nick = Request["nickname"] as string;
         IRepositorioParticipante<Participante> repoPar = new ParticipanteRepositorio();
         IList<Participante> participaciones = repoPar.GetAllByNick(nick);
         if(participaciones!=null)
         {
             IList<int> idsList = new List<int>();
             foreach (var participacione in participaciones)
                 idsList.Add(participacione.IdViaje);
             int[] IdViaje = idsList.ToArray();
             return View(IdViaje);
         }
     }
     return View();
 }