Пример #1
0
        public static string GetMenuUrl(int? id)
        {
            int newId = id ?? 0;

            IMenuRepository service = new MenuRepository();
            if (newId != 0)
            {
                var item = service.Get(newId);
                return item.Url;
            }
            return "";
        }
Пример #2
0
        //public IConfigRepository config { get { return _conf; } private set { _conf = value; } }
        public async Task<ActionResult> Index(string userid = null, string codeAuth = null, string credentialToken = null, int style = 0)
        {

            IConfigRepository _conf = new ConfigRepository();
            IMenuRepository _mrepo = new MenuRepository();
            IProductRepository _mprod = new ProductRepository();
            ViewBag.FirstCat = _mprod.Products.Any() ? _mprod.Products.First().ID : 0;
            if (_conf.Options().SelectedIsOnlineID)
            {
                throw new HttpException(410, "Offline");
            }
            var user = await UserManager.FindByIdAsync(userid);            
            ViewBag.ConfirmEmail = userid != null && !User.Identity.IsAuthenticated && codeAuth == null ? true : false;
            ViewBag.SetPassword = userid != null && codeAuth != null ? true : false;
            ViewBag.UserName = userid != null && !User.Identity.IsAuthenticated ? user.UserName : "";
            ViewBag.UserId = userid != null && codeAuth != null ? userid : "";
            ViewBag.Code = codeAuth != null && userid != null ? codeAuth : "";
            ViewBag.Style = style;
            ViewBag.Token = credentialToken;
            ViewBag.Titlee = _conf.Options().SiteName;
            var result = _mrepo.Menues.FirstOrDefault(x => x.Url == "Home");
            return View(result);
        }
Пример #3
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapMvcAttributeRoutes();

            routes.MapRoute(
              name: "sitemap.xml",
              url: "sitemap.xml",
              defaults: new { controller = "Config", action = "SitemapXml" },
              namespaces: new[] { "x_nova.Areas.Admin.Controllers" }
              );

            routes.MapRoute(
                name: "robots.txt",
                url: "robots.txt",
                defaults: new { controller = "Config", action = "RobotsText" },
                namespaces: new[] { "x_nova.Controllers" }
            );

            routes.Add("ProductDetails", new SeoFriendlyRoute("products/{id}",
             new RouteValueDictionary(new { controller = "Product", action = "Details" }),
             new MvcRouteHandler()));

            routes.MapRoute(
               name: "news",
               url: "Post",
               defaults: new { controller = "Post", action = "Index" },
               namespaces: new[] { "x_nova_template.Controllers" }

               );
            routes.MapRoute(
             name: "photog",
             url: "Photogallery",
             defaults: new { controller = "PhotoGallery", action = "Index" },
             namespaces: new[] { "x_nova_template.Controllers" }

             );
            routes.MapRoute(
               name: "login",
               url: "Account/Login",
               defaults: new { controller = "Account", action = "Login" },
               namespaces: new[] { "x_nova_template.Controllers" }

               );

            /*      routes.MapRoute(
             name: "port",
             url: "{culture}/{controller}",
             defaults: new { culture=CultureHelper.GetDefaultCulture(), controller = "Portfolio", action = "Index" },
             namespaces: new[] { "Qualityequip.Controllers" }
            );
                  routes.MapRoute(
              name: "order",
              url: "{culture}/{controller}",
              defaults: new { culture = CultureHelper.GetDefaultCulture(), controller = "MakeOrder", action = "Index" },
              namespaces: new[] { "Qualityequip.Controllers" }
              );*/
            IMenuRepository _repository = new MenuRepository();
            string[] excludeUrl = { "Post", "tobuy","Home","PhotoGallery" };
            foreach (var item in _repository.Menues.Where(x => !excludeUrl.Contains(x.Url)))
            {

                if (item.ParentId > 0)
                {
                    routes.MapRoute(
                    name: "Menu" + item.Id,
                    url: MenuController.GetMenuUrl(item.ParentId) + "/" + item.Url,
                    defaults: new { controller = "Dynamic", action = "Indexx", routes = item.Url },
                    namespaces: new[] { "x_nova_template.Controllers" }
                    );
                }
                else
                {
                    routes.MapRoute(
                    name: "Menu" + item.Id,
                    url: item.Url,
                    defaults: new { controller = "Dynamic", action = "Indexx", routes = item.Url },
                    namespaces: new[] { "x_nova_template.Controllers" }
                    );
                }

            }
            routes.MapRoute(
                name: "home",
                url: "main",
                defaults: new { controller = "Home", action = "Index" },
                namespaces: new[] { "x_nova_template.Controllers" }
            );
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Product", action = "ProdList", id=UrlParameter.Optional},
                namespaces: new[] { "x_nova_template.Controllers" }
            );
        }