Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            var hostUrl = Helper.GetHostURL();
            var defaultShippingFee = Helper.GetDefaultShippingFee();
            var defaultTax = Helper.GetDefaultTax();
            var countries = Helper.GetCountries();

            var isUserLogedIn = HttpContext.Current.User.Identity.IsAuthenticated;
            var userName = Page.User.Identity.Name;
            var userStore = new Microsoft.AspNet.Identity.EntityFramework.UserStore<Microsoft.AspNet.Identity.EntityFramework.IdentityUser>();
            var userManager = new Microsoft.AspNet.Identity.UserManager<Microsoft.AspNet.Identity.EntityFramework.IdentityUser>(userStore);
            var user = userManager.FindByNameAsync(userName);
            string userId = null;
            if (user.Result != null)
            {
                userId = user.Result.Id;
            }

            PushDataToClient();

            //Push master page data to client
            MasterPageData data = new MasterPageData();
            data.HostUrl = hostUrl;
            data.IsUserLogedIn = isUserLogedIn;
            data.User = user.Result;
            data.Basket = ProductController.GetBasket(0, userId);
            data.DefaultShippingFee = defaultShippingFee;
            data.DefaultTax = defaultTax;
            data.Countries = countries;
            var dataJson = new JavaScriptSerializer().Serialize(data);
            MasterPageDataDiv.InnerHtml = dataJson;
        }
    }
Пример #2
0
    private void BindData()
    {
        int product_id = 0;

        Int32.TryParse(Request.QueryString["product_id"], out product_id);
        if (product_id > 0)
        {
            using (var context = new WebsiteTTKEntities())
            {
                //Get loged in user info
                System.Threading.Tasks.Task <Microsoft.AspNet.Identity.EntityFramework.IdentityUser> user = null;
                if (User.Identity.IsAuthenticated)
                {
                    var userName    = User.Identity.Name;
                    var userStore   = new Microsoft.AspNet.Identity.EntityFramework.UserStore <Microsoft.AspNet.Identity.EntityFramework.IdentityUser>();
                    var userManager = new Microsoft.AspNet.Identity.UserManager <Microsoft.AspNet.Identity.EntityFramework.IdentityUser>(userStore);
                    user = userManager.FindByNameAsync(userName);
                }

                //Get product data
                ProductControllerModel model = ProductController.GetProductDetailData(product_id, user);
                if (model != null)
                {
                    //Throw data to client for script to generate the interface of product
                    var productDetailJson = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(model);
                    ProductControllerModel_Data.InnerText = productDetailJson;

                    //Because product slider cannot be modify after script carousel is loaded.
                    //Thus, we generate the slider on server first to help slider load before carousel script run.
                    MakeupProduct(model);
                }
            }
        }
    }
Пример #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string             hostUrl = Helper.GetHostURL();
         System.Web.UI.Page page    = new System.Web.UI.Page();
         System.Threading.Tasks.Task <Microsoft.AspNet.Identity.EntityFramework.IdentityUser> user;
         if (page.User.Identity.IsAuthenticated)
         {
             var userName    = page.User.Identity.Name;
             var userStore   = new Microsoft.AspNet.Identity.EntityFramework.UserStore <Microsoft.AspNet.Identity.EntityFramework.IdentityUser>();
             var userManager = new Microsoft.AspNet.Identity.UserManager <Microsoft.AspNet.Identity.EntityFramework.IdentityUser>(userStore);
             user = userManager.FindByNameAsync(userName);
             if (user.Result != null)
             {
                 string userId = user.Result.Id;
                 BindData(userId, hostUrl);
             }
         }
         else
         {
             Response.Redirect(hostUrl);
         }
     }
 }
Пример #4
0
    protected void btnSubmitPaymentMethod_Click(object sender, EventArgs e)
    {
        string hostUrl = Helper.GetHostURL();

        System.Web.UI.Page page = new System.Web.UI.Page();
        System.Threading.Tasks.Task <Microsoft.AspNet.Identity.EntityFramework.IdentityUser> user;
        if (page.User.Identity.IsAuthenticated)
        {
            var userName    = page.User.Identity.Name;
            var userStore   = new Microsoft.AspNet.Identity.EntityFramework.UserStore <Microsoft.AspNet.Identity.EntityFramework.IdentityUser>();
            var userManager = new Microsoft.AspNet.Identity.UserManager <Microsoft.AspNet.Identity.EntityFramework.IdentityUser>(userStore);
            user = userManager.FindByNameAsync(userName);
            if (user.Result != null)
            {
                string userId = user.Result.Id;

                var deliveryId    = Helper.GetPlainTextFromHtml(txtDeliveryId.Text);
                var currentUserId = Helper.GetPlainTextFromHtml(txtUserId.Text);
                if (currentUserId == userId && !String.IsNullOrEmpty(currentUserId))
                {
                    int delivery_id = 0;
                    int.TryParse(deliveryId, out delivery_id);
                    if (delivery_id > 0)
                    {
                        var result = OrderHelper.UpdateNewOrderShippingCost(userId, delivery_id);
                        if (result != null)
                        {
                            ClientScript.RegisterStartupScript(GetType(), "ShowAlert", "window.ShowMessage(0,\"" + result + "\",true);", true);
                        }
                        else
                        {
                            Response.Redirect(hostUrl + "/checkout3.aspx");
                        }
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(GetType(), "ShowAlert", "window.ShowMessage(0,\"" + "Missing delivery method!" + "\",true);", true);
                    }
                }
                else
                {
                    ClientScript.RegisterStartupScript(GetType(), "ShowAlert", "window.ShowMessage(0,\"" + "Current user doesn't fix your query!" + "\",true);", true);
                }
            }
            else
            {
                ClientScript.RegisterStartupScript(GetType(), "ShowAlert", "window.ShowMessage(0,\"" + "Please login to continue!" + "\",true);", true);
            }
        }
        else
        {
            Response.Redirect(hostUrl);
        }
    }