Ejemplo n.º 1
0
        public ActionResult Product(int productId, string message = null)
        {
            ViewData["BreadCrumbs"] = new List <BreadCrumb> {
                new BreadCrumb {
                    Url = UrlMaker.ToDefault(), Title = "home"
                },
                new BreadCrumb {
                    Url = UrlMaker.ToShopping(), Title = "shopping"
                },
                new BreadCrumb {
                    Url = UrlMaker.ToProducts(), Title = "product catalog"
                },
                new BreadCrumb {
                    Title = "product details"
                }
            };

            ViewData["ProductImage"] = imageService + "GetProductImage/" + productId;

            if (message != null)
            {
                ModelState.AddModelError("Message", message);
            }

            return(View(_productRepository.Get(productId).ToModel()));
        }
Ejemplo n.º 2
0
        // establishes the composite menu hierarchy which is present on all pages.

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // build the composite menu tree
                // this tree implements the Composite Design Pattern

                var root = new MenuCompositeItem("root", null);
                var home = new MenuCompositeItem("home", UrlMaker.ToDefault());
                var shop = new MenuCompositeItem("shopping", UrlMaker.ToShopping());
                var prod = new MenuCompositeItem("products", UrlMaker.ToProducts());
                var srch = new MenuCompositeItem("search", UrlMaker.ToSearch());
                var admn = new MenuCompositeItem("administration", UrlMaker.ToAdmin());
                var cust = new MenuCompositeItem("members", UrlMaker.ToMembers());
                var ordr = new MenuCompositeItem("orders", UrlMaker.ToOrders());

                MenuCompositeItem auth;
                if (Request.IsAuthenticated)
                {
                    auth = new MenuCompositeItem("logout", UrlMaker.ToLogout());
                }
                else
                {
                    auth = new MenuCompositeItem("login", UrlMaker.ToLogin());
                }

                shop.Children.Add(prod);
                shop.Children.Add(srch);
                admn.Children.Add(cust);
                admn.Children.Add(ordr);
                root.Children.Add(home);
                root.Children.Add(shop);
                root.Children.Add(admn);
                root.Children.Add(auth);


                TheMenuComposite.MenuItems = root;
            }
        }