public ActionResult Create(Destino Destino,string Button, Map map)
        {
            var idViaje = Convert.ToInt32(Request["idViaje"]);

            if (Button == "Agregar Destino")
            {
                IRepositorio<Destino> repo = new DestinoRepositorio();
                IRepositorio<Viaje> repoViaje = new ViajeRepositorio();
                Destino.Viaje = repoViaje.GetById(idViaje);
                PhotoSearchOptions options = new PhotoSearchOptions();
                options.Extras |= PhotoSearchExtras.Geo;
                options.Tags = map.Name;
                options.HasGeo = true;
                options.PerPage = 24;
                Flickr flickr = new Flickr("3de826e278b4988011ef0227585a7838", "81a96df44a82b16c");
                photos = flickr.PhotosSearch(options);
                foreach (Photo photo in photos)
                {
                    if (Destino.Url != null)
                    {
                        if (Destino.Url.CompareTo(photo.SmallUrl) == 0)
                        {
                            Destino.Latitud = photo.Latitude;
                            Destino.Longitud = photo.Longitude;
                            Destino.Nombre = photo.Title;
                        }
                    }else
                    {
                        ModelState.AddModelError(string.Empty,"Es Necesario que escoja una foto!");
                        return View();
                    }
                }
                repo.Save(Destino);
                int id2 = idViaje;
                ViewData["idViaje"] = id2;
                return RedirectToAction("Index", "Destino", new { idViaje = id2 });
            }
            else {
                int i = 0;
                PhotoSearchOptions options = new PhotoSearchOptions();
                //options.BoundaryBox = new BoundaryBox(-1.7, 54.9, -1.4, 55.2); // Roughly Newcastle upon Type, England
                //options.BoundaryBox = BoundaryBox.World;
                options.Extras |= PhotoSearchExtras.Geo;
                options.Tags = map.Name;
                options.HasGeo = true;
                options.PerPage = 24;

                Flickr flickr = new Flickr("18ead65365e9b505cc7f97abd38a33fe", "1b0f7df21b450da8");

                photos = flickr.PhotosSearch(options);
                foreach (Photo photo in photos)
                {
                    ViewData["Message"] = String.Format("Lugares de \"{0}\".", map.Name);
                    ViewData.Add(("Message" + i), photo.SmallUrl);
                    i++;
                }
                int id2 = idViaje;
                ViewData["idViaje"] = id2;

                return View();
            }
        }
        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");
        }
 public ActionResult Edit(Destino Destino, int id, int idViaje)
 {
     IRepositorio<Viaje> repoViaje = new ViajeRepositorio();
     Destino.Viaje = repoViaje.GetById(idViaje);
     IRepositorio<Destino> repo = new DestinoRepositorio();
     repo.Update(Destino);
     int id2 = idViaje;
     ViewData["idViaje"] = id2;
     return RedirectToAction("Index", "Destino", new { idViaje = id2 });
 }
        public ActionResult Viaje()
        {
            if (Request["idviaje"] != "")
            {
                int idViajeConsulta = Convert.ToInt32(Request["idviaje"]);
                IRepositorio<Destino> repoDes = new DestinoRepositorio();
                IList<Destino> destinos = repoDes.GetAll();
                IList<DestinoXml> destinosViaje = new List<DestinoXml>();
                _cont = 0;
                foreach (Destino destino in destinos)
                {

                    if (destino.Viaje.IdViaje == idViajeConsulta)
                    {
                        if (destino.Fecha != null)

                            destinosViaje.Add(new DestinoXml
                                                  {
                                                      Descripcion = destino.Descripcion,
                                                      Direccion = destino.Direccion,
                                                      Fecha = (DateTime) destino.Fecha,
                                                      IdDestino = destino.IdDestino,
                                                      Latitud = destino.Latitud,
                                                      Longitud = destino.Longitud,
                                                      Nombre = destino.Nombre,
                                                      UrlFoto = destino.Url
                                                  });
                    }

                }
                DestinoXml[] Dest = destinosViaje.ToArray();
                IRepositorio<Viaje> repo = new ViajeRepositorio();
                Viaje viaje = repo.GetById(idViajeConsulta);
                if (viaje != null)
                {
                    ViajeXml[] v = new[]
                                       {
                                           new ViajeXml
                                               {
                                                   Destino = viaje.Destino,
                                                   FechaInicio = viaje.FechaInicio,
                                                   FechaFin = viaje.FechaFin,
                                                   Hospedaje = viaje.Hospedaje,
                                                   IdViaje = viaje.IdViaje,
                                                   Nombre = viaje.Nombre,
                                                   Privacidad = viaje.Privacidad,
                                                   Destinos = Dest
                                               }
                                       };

                    return View(v);
                }
            }
            return View();
        }