Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ClientScript.RegisterStartupScript(GetType(), "hwa", "getTweets();", true);
        //create customer if customer does not exist in session
        try
        {
            if (HttpContext.Current.Session["Customer"] == null)
            {
                Customer aCustomer;
                aCustomer           = CartFunctions.createCustomer();
                Session["Customer"] = aCustomer;
            } //end if
        }     //end try
        catch (Exception)
        {
        }//end catch

        try
        {
            //check to see if user is logged on, if so assigns user id to CUSTID in customer object
            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                string   custID;
                Customer aCustomer = (Customer)Session["Customer"];

                MembershipUser user = Membership.GetUser();
                custID           = user.ProviderUserKey.ToString();
                aCustomer.CUSTID = custID;
            } //end if
        }     //end try
        catch (Exception)
        {
        }//end catch

        try
        {
            //getWeather();
        }//end try
        catch (Exception)
        {
        }//end catch

        try
        {
            //if its a new session get products list from database and add it so session variable
            if (Session.IsNewSession)
            {
                ShopDataContext dc = new ShopDataContext();

                da = new DataAccess();
                List <Product> p = da.getProducts();
                Session["Products"] = p;
            } //endif
        }     //end try
        catch (Exception)
        {
        }//end catch

        getLatestProducts();
    }