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."; } } }
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."; } } }
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())); }
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())); }
// 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; }
// 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; } }