Пример #1
0
        public int GetLastOrderId()
        {
            // Add your operation implementation here
            var repo = new OrderRepository();
            var customerRepo = new CustomerRepository();

            var authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
            if (authCookie == null)
                throw new Exception("Not logged in.");
            var authTicket = FormsAuthentication.Decrypt(authCookie.Value);
            var customerId = customerRepo.GetCustomerByUsername(authTicket.Name).CustomerId;
            var order = repo.GetAllOrdersByCustomerId(customerId).OrderByDescending(o => o.OrderId).First();
            return order.OrderId;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var customerRepository = new CustomerRepository();
            var customer = customerRepository.GetCustomerByUsername(User.Identity.Name);
            if (customer == null)
            {
                lblFeedback.Text = "We don't recognize your customer Id. Please log in and try again.";
                return;
            }

            lblCustomerInfo.Text = customer.ToHtml("viewAccountInfoDiv");

            lblCustomerInfo.Text += string.Format(
                "<div class='clear'><a href='ChangeAccountInfo.aspx?Id={0}'>Change your account info.</a></div>",
                customer.ContactName    // ContactName is being repurposed as the foreign key to the user table.  Kludgey, I know.
                );
        }
Пример #3
0
        protected void RegisterUser_CreatedUser(object sender, EventArgs e)
        {
            var address = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("txtAddress")).Text;
            var city = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("txtCity")).Text;
            var region = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("txtRegion")).Text;
            var postalCode = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("txtPostalCode")).Text;
            var country = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("txtCountry")).Text;

            var repo = new CustomerRepository();
            repo.CreateCustomer(_companyName, _contactName, address, city, region, postalCode, country);

            FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */);
            string continueUrl = RegisterUser.ContinueDestinationPageUrl;
            if (String.IsNullOrEmpty(continueUrl))
            {
                continueUrl = "~/";
            }
            Response.Redirect(continueUrl);
        }