Пример #1
0
        public ActionResult Business(int id, string name)
        {
            // load business
            var business = new viadflib.DataContext().Businesses.FirstOrDefault(x => x.ID == id);

            if (business != null && business.SeoName == name)
            {
                var model = new BusinessModel();

                model.Business            = business;
                model.Business.Name       = Utils.Capitalize(business.Name);
                model.ConnectingRoutes    = DataHandler.GetConnectionRoutes(business.Lat, business.Lng, 0.25);
                model.CloseBusinesses     = DataHandler.GetCloseBusinesses(business, 0.25, 50);
                model.SmallSearchBoxModel = new SmallSearchBoxModel {
                    Name = Utils.Capitalize(model.Business.Name), Coordinates = Utils.FormatCoordinates(business.Lat, business.Lng)
                };

                model.Colonia = DataHandler.GetColoniaAtPosition(business.Lat, business.Lng);

                SetSEO(model.Business.Name + " - ¿Cómo llegar en transporte público?", "Usa ViaDF para saber cómo llegar en transporte público a " + model.Business.Name + " (" + model.Business.Category + ")" + (model.Colonia == null ? "" : " en " + Utils.Capitalize(model.Colonia.Name) + ", " + Utils.Capitalize(model.Colonia.Delegacion.Name)), model.Business.Name);

                return(View(model));
            }

            return(HttpNotFound());
        }
Пример #2
0
        public ActionResult LastSearches(int?count)
        {
            int historyCount = count ?? 5;

            using (var context = new viadflib.DataContext())
            {
                List <SearchHistory> history = context.SearchHistories.Where(x => x.FromName != null && x.ToName != null && x.FromName.Length > 0 && x.ToName.Length > 0).OrderByDescending(x => x.ID).Take(historyCount).ToList();
                return(View(history));
            }
        }
Пример #3
0
        public ActionResult Route(int?id, string type, string name)
        {
            // legacy seo url redirect
            if (id.HasValue)
            {
                RouteData.Values.Remove("id");
                return(new PermanentRedirectResult(Url.Action("Route", new { type = Utils.Capitalize(type), name = Utils.Capitalize(name) })));
            }

            // load type
            var typeObj = new viadflib.DataContext().Types.Where(x => x.SeoName == type.ToLower()).FirstOrDefault();

            if (typeObj != null)
            {
                // load route
                var routeObj = new viadflib.DataContext().Routes.Where(x => x.Status > (int)StatusEnum.New && (x.SeoName == name.ToLower() || x.OldSeoName == name.ToLower()) && x.TypeID == typeObj.ID).FirstOrDefault();

                if (routeObj != null)
                {
                    if (routeObj.OldSeoName == name.ToLower() && routeObj.SeoName != name.ToLower())
                    {
                        return(RedirectToActionPermanent("Route", new { type = Utils.Capitalize(typeObj.SeoName), name = Utils.Capitalize(routeObj.SeoName) }));
                    }

                    RouteModel model = new RouteModel();

                    model.Route       = DataHandler.GetRoute(routeObj.ID);
                    model.RoutePieces = DataHandler.GetRoutePieces(routeObj.ID);
                    if (!model.Route.Type.HasNamedStationList)
                    {
                        model.RouteStreets  = DataHandler.GetRouteStreets(routeObj.ID);
                        model.RouteColonias = DataHandler.GetRouteColonias(routeObj.ID);
                    }
                    if (model.Route.SplitRoutePieceID.HasValue)
                    {
                        model.RoutePieces1 = model.RoutePieces.Where(x => x.ID <= model.Route.SplitRoutePieceID).OrderBy(x => x.ID).ToList();
                        model.RoutePieces2 = model.RoutePieces.Where(x => x.ID >= model.Route.SplitRoutePieceID).OrderBy(x => x.ID).ToList();
                    }
                    else
                    {
                        model.RoutePieces1 = model.RoutePieces;
                    }

                    var routeName = model.Route.TypeID == (int)TypeEnum.Microbus ? model.Route.FromName + " a " + model.Route.ToName : "(" + model.Route.Name + ")";

                    SetSEO(model.Route.Type.Name + " " + routeName + " - ¿Cómo llegar en transporte público?", "", model.Route.Type.Name + "," + model.Route.Name);

                    return(View(model));
                }
            }
            return(HttpNotFound());
        }
Пример #4
0
        public ActionResult Map()
        {
            MapModel model = new MapModel();

            using (var context = new viadflib.DataContext())
            {
                model.AllTypes = context.Types.Where(x => x.ShowInWeb).ToList();
            }

            SetSEO("Mapa interactivo del transporte público en la Ciudad de México.", "Mapa interactivo con todas las rutas del transporte público en la Ciudad de México y en el Estado de México.", "mapa interactivo, lista rutas, transporte público, méxico, ciudad de méxico, cdmx, estado de méxico");

            return(View(model));
        }
Пример #5
0
        public ActionResult RoutePiece(int?id, string type, string route, string name)
        {
            // legacy seo url redirect
            if (id.HasValue)
            {
                RouteData.Values.Remove("id");
                return(new PermanentRedirectResult(Url.Action("RoutePiece", new { type = type, route = route, name = name })));
            }

            // load type
            var typeObj = new viadflib.DataContext().Types.Where(x => x.SeoName == type.ToLower()).FirstOrDefault();

            if (typeObj != null)
            {
                // load route
                var routeObj = new viadflib.DataContext().Routes.Where(x => (x.SeoName == route.ToLower() || x.OldSeoName == route.ToLower()) && x.TypeID == typeObj.ID).FirstOrDefault();

                if (routeObj != null)
                {
                    var routePieceObj = new viadflib.DataContext().RoutePieces.Where(x => x.SeoName == name.ToLower() && x.RouteID == routeObj.ID).FirstOrDefault();

                    if (routePieceObj != null)
                    {
                        if (routeObj.OldSeoName == name.ToLower() && routeObj.SeoName != name.ToLower())
                        {
                            return(RedirectToActionPermanent("RoutePiece", new { type = Utils.Capitalize(typeObj.SeoName), route = Utils.Capitalize(routeObj.SeoName), name = Utils.Capitalize(routePieceObj.SeoName) }));
                        }

                        RoutePieceModel model = new RoutePieceModel();
                        model.RoutePiece       = DataHandler.GetRoutePiece(routePieceObj.ID);
                        model.ConnectingRoutes = DataHandler.GetConnectionRoutes(model.RoutePiece, 0.5);
                        model.CloseBusinesses  = DataHandler.GetCloseBusinesses(model.RoutePiece, 0.25, 50);
                        string routeName = model.RoutePiece.Route.Type.Name + " " + model.RoutePiece.Name;

                        model.SmallSearchBoxModel = new SmallSearchBoxModel {
                            Name = routeName, Coordinates = Utils.FormatCoordinates(model.RoutePiece.Lat, model.RoutePiece.Lng)
                        };

                        routeName += " (" + model.RoutePiece.Route.Name + ")";
                        SetSEO(routeName + " - ¿Cómo llegar en transporte público?", "", model.RoutePiece.Route.Type.Name + "," + model.RoutePiece.Name + "," + model.RoutePiece.Route.Name);

                        return(View(model));
                    }
                }
            }

            return(HttpNotFound());
        }
Пример #6
0
        public ActionResult Colonia(int estadoId, string delegacion, string name, int?id)
        {
            // legacy seo url redirect
            if (id.HasValue)
            {
                RouteData.Values.Remove("id");
                return(new PermanentRedirectResult(Url.Action("Colonia", new { estadoId = estadoId, delegacion = delegacion, name = name })));
            }

            // load delegacion
            var delegacionObj = new viadflib.DataContext().Delegacions.Where(x => x.SeoName == delegacion.ToLower()).FirstOrDefault();

            if (delegacionObj != null)
            {
                // load colonia
                var colonia = new viadflib.DataContext().Colonias.Where(x => x.SeoName == name.ToLower() && x.DelegacionID == delegacionObj.ID).FirstOrDefault();

                if (colonia != null)
                {
                    ColoniaRouteListModel model = new ColoniaRouteListModel();
                    model.Colonia = colonia;
                    model.Routes  = new viadflib.DataContext().Routes.Where(x => x.RoutePieces.Count(y => y.StreetCrossing.Street.ColoniaID == model.Colonia.ID) > 0 && x.Status != (int)StatusEnum.New).ToList();
                    StreetCrossing firstCrossing = new viadflib.DataContext().StreetCrossings.Where(x => x.Street.ColoniaID == model.Colonia.ID).FirstOrDefault();
                    if (firstCrossing != null)
                    {
                        model.SmallSearchBoxModel = new SmallSearchBoxModel()
                        {
                            Name = Utils.Capitalize(model.Colonia.Name) + " en " + Utils.Capitalize(model.Colonia.Delegacion.Name), Coordinates = Utils.FormatCoordinates(firstCrossing.Lat, firstCrossing.Lng)
                        };;
                    }

                    SetSEO("Transporte público en " + Utils.Capitalize(model.Colonia.Name) + " (" + Utils.Capitalize(model.Colonia.Delegacion.Name) + ") - ¿Cómo llegar en transporte público?", "", Utils.Capitalize(model.Colonia.Delegacion.Name) + "," + Utils.Capitalize(model.Colonia.Name));

                    return(View(model));
                }
            }

            return(HttpNotFound());
        }
Пример #7
0
        public ActionResult Delegacion(int estadoId, string name, int?id)
        {
            // legacy seo url redirect
            if (id.HasValue)
            {
                RouteData.Values.Remove("id");
                return(new PermanentRedirectResult(Url.Action("Delegacion", new { estadoId = estadoId, name = name })));
            }

            // if none loaded - redirect to main page of state
            if (name == null)
            {
                if (estadoId == 1)
                {
                    return(RedirectToAction("Delegacion", new { estadoId = estadoId, name = "Alvaro-Obregon" }));
                }
                else
                {
                    return(RedirectToAction("Delegacion", new { estadoId = estadoId, name = "Atizapan-De-Zaragoza" }));
                }
            }

            // load delegacion
            var delegacion = new viadflib.DataContext().Delegacions.Where(x => x.SeoName == name.ToLower()).FirstOrDefault();

            if (delegacion != null)
            {
                DelegacionListModel model = new DelegacionListModel();

                model.Delegacion = delegacion;
                model.All        = new viadflib.DataContext().Delegacions.Where(x => x.EstadoID == model.Delegacion.EstadoID).OrderBy(x => x.Name).ToList();
                model.Colonias   = new viadflib.DataContext().Colonias.Where(x => x.DelegacionID == model.Delegacion.ID).OrderBy(x => x.Name).ToList();

                SetSEO("Transporte público en " + Utils.Capitalize(model.Delegacion.Name) + " - ¿Cómo llegar en transporte público?", "", Utils.Capitalize(model.Delegacion.Name));
                return(View(model));
            }

            return(HttpNotFound());
        }
Пример #8
0
        public ActionResult RouteList(string type)
        {
            RouteListModel model = new RouteListModel();

            using (var context = new viadflib.DataContext())
            {
                model.AllTypes = context.Types.Where(x => x.ShowInWeb).ToList();
                if (type != null)
                {
                    model.SelectedType = model.AllTypes.FirstOrDefault(x => x.SeoName == (type ?? "").ToLower());
                    if (model.SelectedType != null)
                    {
                        model.Routes = context.Routes.Where(x => x.TypeID == model.SelectedType.ID && x.Status > (int)StatusEnum.New).OrderBy(x => x.Name).ToList();
                    }
                    else
                    {
                        return(HttpNotFound());
                    }
                }
                else
                {
                    model.Routes = new List <Route>();
                }
            }

            if (model.SelectedType != null)
            {
                SetSEO("Lista de rutas del " + model.SelectedType.Name + " de la Ciudad de México.", "Lista de todas las rutas del " + model.SelectedType.Name + "en la Ciudad de México y en el Estado de México.", model.SelectedType.Name + ", como llegar, como llego, lista rutas, transporte público, méxico, ciudad de méxico, cdmx, estado de méxico");
            }
            else
            {
                SetSEO("Directorio del transporte público de la Ciudad de México.", "Directorio de las rutas y estaciones del transporte público en la Ciudad de México y en el Estado de México.", "directorio, como llegar, como llego, lista rutas, transporte público, méxico, ciudad de méxico, cdmx, estado de méxico");
            }

            return(View(model));
        }