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
        protected void ButtonSubmit_Click(object sender, System.EventArgs e)
        {
            string username = TextboxUserName.Text.Trim();
            string password = TextboxPassword.Text.Trim();

            var repository = new AuthRepository();

            if (repository.Login(username, password))
            {
                FormsAuthentication.SetAuthCookie(username, false);

                string redirectUrl = FormsAuthentication.GetRedirectUrl(username, false);
                if (redirectUrl != null && redirectUrl.IndexOf("admin") >= 0)
                {
                    FormsAuthentication.RedirectFromLoginPage(username, false);
                }
                else
                {
                    Response.Redirect(UrlMaker.ToAdmin());
                }
            }
            else
            {
                if (Tries >= 2)
                {
                    Response.Redirect(UrlMaker.ToDefault());
                }
                else
                {
                    Tries += 1;
                    this.LiteralError.Text = "Invalid Username or Password. Please try again.";
                }
            }
        }
Ejemplo n.º 3
0
        protected void ButtonSubmit_Click(object sender, System.EventArgs e)
        {
            string email    = TextboxEmail.Text.Trim();
            string password = TextboxPassword.Text.Trim();

            var service = new Service();

            if (service.Login(email, password))
            {
                string redirectUrl = FormsAuthentication.GetRedirectUrl(email, false);
                if (redirectUrl != null && redirectUrl.IndexOf("admin") >= 0)
                {
                    FormsAuthentication.RedirectFromLoginPage(email, false);
                }
                else
                {
                    Response.Redirect(UrlMaker.ToAdmin());
                }
            }
            else
            {
                if (Tries >= 5)
                {
                    Response.Redirect(UrlMaker.ToDefault());
                }
                else
                {
                    Tries += 1;
                    this.LiteralError.Text = "Invalid Username or Password. Please try again.";
                }
            }
        }
Ejemplo n.º 4
0
        public ActionResult OrderDetails(int customerId, int orderId)
        {
            var order = _orderRepository.Get(orderId);

            ViewData["OrderDate"]   = "Order Date: " + string.Format("{0:MM/dd/yyyy}", order.OrderDate);
            ViewData["BreadCrumbs"] = new List <BreadCrumb> {
                new BreadCrumb {
                    Url = UrlMaker.ToDefault(), Title = "home"
                },
                new BreadCrumb {
                    Url = UrlMaker.ToAdmin(), Title = "administration"
                },
                new BreadCrumb {
                    Url = UrlMaker.ToOrders(), Title = "orders"
                },
                new BreadCrumb {
                    Url = UrlMaker.ToCustomerOrders(customerId), Title = "customer orders"
                },
                new BreadCrumb {
                    Title = "line items"
                }
            };

            return(View(order.OrderDetails.ToList().ToModel()));
        }
Ejemplo n.º 5
0
        public ActionResult CustomerOrders(int customerId)
        {
            ViewData["CustomerId"] = customerId;

            var customer = _customerRepository.GetCustomerWithOrders(
                new Criterion("CustomerId", Operator.Equals, customerId));

            ViewData["Company"]     = customer.Company;
            ViewData["BreadCrumbs"] = new List <BreadCrumb> {
                new BreadCrumb {
                    Url = UrlMaker.ToDefault(), Title = "home"
                },
                new BreadCrumb {
                    Url = UrlMaker.ToAdmin(), Title = "administration"
                },
                new BreadCrumb {
                    Url = UrlMaker.ToOrders(), Title = "orders"
                },
                new BreadCrumb {
                    Title = "customer orders"
                }
            };

            return(View(customer.Orders.ToList().ToModel()));
        }
Ejemplo n.º 6
0
        public ActionResult Login()
        {
            ViewData["BreadCrumbs"] = new List <BreadCrumb> {
                new BreadCrumb {
                    Url = UrlMaker.ToDefault(), Title = "home"
                },
                new BreadCrumb {
                    Title = "login"
                }
            };

            return(View(new LoginModel()));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Action method. Performs a logout for current user.
        /// </summary>
        /// <returns></returns>
        public ActionResult Logout()
        {
            _authRepository.Logout();
            FormsAuthentication.SignOut();

            ViewData["BreadCrumbs"] = new List <BreadCrumb> {
                new BreadCrumb {
                    Url = UrlMaker.ToDefault(), Title = "home"
                },
                new BreadCrumb {
                    Title = "logout"
                }
            };
            return(View());
        }
Ejemplo n.º 8
0
        // private Helper
        private void SetCustomerViewData(int?customerId = 0)
        {
            ViewData["BreadCrumbs"] = new List <BreadCrumb> {
                new BreadCrumb {
                    Url = UrlMaker.ToDefault(), Title = "home"
                },
                new BreadCrumb {
                    Url = UrlMaker.ToAdmin(), Title = "administration"
                },
                new BreadCrumb {
                    Url = UrlMaker.ToCustomers(), Title = "customers"
                },
                new BreadCrumb {
                    Title = "customer details"
                }
            };

            ViewData["CustomerImage"] = imageService + "GetCustomerImageLarge/" + customerId;
        }
Ejemplo n.º 9
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;
            }
        }