//
        // GET: /Destino/
        public ActionResult Index(int idViaje)
        {
            int id2 = idViaje;
            ViewData["idViaje"] = id2;
            IRepositorio<Destino> repo = new DestinoRepositorio();
            IList<Destino> destinos = repo.GetAll();
            IList<Destino> destinosViaje = new List<Destino>();
            IRepositorioComentario<Comentario> repoC = new ComentarioRepositorio();
            using (var session = new MongoSession<Category>())
            {

                foreach (Destino destino in destinos)
                {
                    if (destino.Viaje.IdViaje == id2)
                    {
                        Destino destino1 = destino;
                        var category = session.Queryable
                          .Where(c => c.IdDestino == destino1.IdDestino)
                          .AsEnumerable();
                        destino.Votos = category!=null ? category.Count() : 0;
                        IList<Comentario> comentarios = repoC.GetAll();
                        destino.Comentarios = new List<Comentario>();
                        foreach (var comentario in comentarios)
                        {
                            if(comentario.IdDestino == destino.IdDestino)
                            destino.Comentarios.Add(comentario);
                        }

                        destinosViaje.Add(destino);
                    }
                }
            }

            return View(destinosViaje);
        }
        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();
        }