예제 #1
0
    protected void addtoCart_Click(object sender, EventArgs e)
    {
        //add certain number of selected product to cart
        List <Product> p         = (List <Product>)Session["Products"];
        Customer       aCustomer = (Customer)Session["Customer"];

        int qty    = Convert.ToInt16(txtQuantity.Text);
        int prodId = Convert.ToInt16(Request.QueryString["id"]);

        aCustomer = CartFunctions.addItemtoCart(p, aCustomer, prodId, qty);

        lblQty.Text         = txtQuantity.Text + " ";
        lblProduct.Text     = "x " + lblProdTitle.Text + " added to your cart";
        Session["Customer"] = aCustomer;

        //displays products bought with
        ClientScript.RegisterStartupScript(GetType(), "hwa", "confirmOrder();", true);

        Label lblCost = (Label)this.Master.FindControl("lblCost");

        lblCost.Text = CartFunctions.getSubTotal(aCustomer).ToString("C");

        Label lblItem = (Label)this.Master.FindControl("lblItems");

        lblItem.Text = CartFunctions.getNumItem(aCustomer).ToString() + " items";
    }
예제 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Customer aCustomer = (Customer)Session["Customer"];

        //if its not a post back display orderlines
        if (!IsPostBack)
        {
            var query = from goods in aCustomer.Orders[0].OrderLines
                        select new
            {
                Name        = goods.Product.ProdName,
                Description = goods.Product.ProdDescription,
                Price       = goods.Product.ProdPrice,
                Qty         = goods.Quantity,
                Total       = "£" + Convert.ToString(goods.Quantity * goods.Product.ProdPrice),
                ProdImage   = goods.Product.ProdImage
            };

            GridView1.DataSource = query;
            GridView1.DataBind();
        }
        //display totals
        subTotal       = CartFunctions.getSubTotal(aCustomer);
        shipping       = Convert.ToDouble(drpPostage.SelectedValue);
        cellSub.Text   = "£" + Convert.ToString(subTotal);
        total          = subTotal + shipping;
        cellTotal.Text = "£" + total;
    }
예제 #3
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();
    }
예제 #4
0
        public ActionResult EmptyCart(int productId, string userName)
        {
            //Method to call whenever user has checked out items in cart
            CartFunctions.EmptyCart(userName);

            return(Redirect(Request.UrlReferrer.ToString()));
        }
예제 #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int    noItems   = 0;
        double dbCostost = 0.00;



        Customer aCustomer = (Customer)Session["Customer"];

        //check if there are orderlines to begin with
        if (aCustomer.Orders[0].OrderLines.Count <= 0)
        {
            //set to default values
            lblItems.Text = noItems.ToString();
            lblCost.Text  = dbCostost.ToString("C");
        }
        else
        {
            //get number of items and total and set labels to them
            noItems   = CartFunctions.getNumItem(aCustomer);
            dbCostost = CartFunctions.getSubTotal(aCustomer);
        }//end if else
        lblCost.Text  = dbCostost.ToString("C");
        lblItems.Text = noItems.ToString() + " items";
    }//end event
예제 #6
0
        public ActionResult RemovefromCart(int productId, string userName)
        {
            //Method to call whenever user decreases quantity by 1 with each click under "My Purchases"
            //To ensure that the decrement button html has limit on how low it can go
            CartFunctions.RemovefromCart(productId, userName);

            return(Redirect(Request.UrlReferrer.ToString()));
        }
예제 #7
0
        public ActionResult AddtoCart(int productId, string userName, string sessionId)
        {
            //Method to call whenever user clicks "Add to Cart" under "Gallery" page/increases quantity under "My Purchases" page
            CartFunctions.AddtoCart(productId, userName);

            ViewData["sessionId"] = sessionId;
            return(Redirect(Request.UrlReferrer.ToString()));
        }
예제 #8
0
        public ActionResult ViewCart(string userName, string sessionId)
        {
            userName = "******";

            carts = CartFunctions.CartList(userName);
            ViewData["username"]  = userName;
            ViewData["sessionId"] = sessionId;
            return(View(carts));
        }
예제 #9
0
        public RedirectToRouteResult RemoveItemCart(CartFunctions cartFunctions, int productId, string url)
        {
            Product product = db.Products.FirstOrDefault(k => k.ProductId == productId);

            if (product != null)
            {
                cartFunctions.RemoveItem(product);
            }
            return(RedirectToAction("CartSummary", new { url }));
        }
예제 #10
0
        public RedirectToRouteResult AddItemToCart(CartFunctions cartFunctions, int productId, string url)
        {
            Product product = db.Products.FirstOrDefault(m => m.ProductId == productId);

            if (product != null)
            {
                cartFunctions.AddItem(product, 1);
            }
            return(RedirectToAction("CartSummary", new { url }));
        }
예제 #11
0
        public void OrderProcess(CartFunctions cartFunctions, Order order)
        {
            using (var smpt = new SmtpClient())
            {
                smpt.UseDefaultCredentials = false;
                smpt.Credentials           = new NetworkCredential(email.Login, email.Password);
                smpt.Host      = email.ServerName;
                smpt.Port      = email.Port;
                smpt.EnableSsl = email.Ssl;

                if (email.File)
                {
                    smpt.DeliveryMethod          = SmtpDeliveryMethod.SpecifiedPickupDirectory;
                    smpt.PickupDirectoryLocation = email.Target;
                    smpt.EnableSsl = false;
                }

                StringBuilder builder = new StringBuilder()
                                        .AppendLine("Zamówienie:")
                                        .AppendLine("");

                foreach (var m in cartFunctions.Cart)
                {
                    var sum = m.Product.Price * m.Number;
                    builder.AppendFormat("{0} x {1}     {2:c}", m.Product.Name, m.Number, sum)
                    .AppendLine("");
                }


                builder.AppendFormat("W sumie:     {0:c}", cartFunctions.SumItem())
                .AppendLine("")
                .AppendLine("")
                .AppendLine("Adres dostawy:")
                .AppendLine(order.FirstName)
                .AppendLine(order.LastName)
                .AppendLine(order.Phone)
                .Append(order.Street + " ").Append(order.House).AppendLine("/" + order.Apartment)
                .Append(order.City + ", ").AppendLine(order.Zip);

                MailMessage message = new MailMessage
                                      (
                    email.UserMail,
                    email.AdminMail,
                    "Nowe zamówienie",
                    builder.ToString()
                                      );

                if (email.File)
                {
                    message.BodyEncoding = Encoding.UTF8;
                }

                smpt.Send(message);
            }
        }
예제 #12
0
 public ViewResult SubmitOrder(CartFunctions cartFunctions, Order order)
 {
     if (ModelState.IsValid)
     {
         processOrder.OrderProcess(cartFunctions, order);
         cartFunctions.Clear();
         return(View("End"));
     }
     else
     {
         return(View(order));
     }
 }
예제 #13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            // Verify user has completed the checkout process.
            if (Session["userCheckoutCompleted"] != "true")
            {
                Session["userCheckoutCompleted"] = "";
                Response.Redirect("CheckoutError.aspx?" + "Desc=Unvalidated%20Checkout.");
            }

            NVPAPICaller payPalCaller = new NVPAPICaller();

            string   retMsg             = "";
            string   token              = "";
            string   finalPaymentAmount = "";
            string   PayerID            = "";
            NVPCodec decoder            = new NVPCodec();

            token              = Session["token"].ToString();
            PayerID            = Session["payerId"].ToString();
            finalPaymentAmount = Session["payment_amt"].ToString();

            bool ret = payPalCaller.DoCheckoutPayment(finalPaymentAmount, token, PayerID, ref decoder, ref retMsg);
            if (ret)
            {
                // Retrieve PayPal confirmation value.
                string PaymentConfirmation = decoder["PAYMENTINFO_0_TRANSACTIONID"].ToString();
                TransactionId.Text = PaymentConfirmation;

                // Get dataaccess context.
                DataAccess da        = new DataAccess();
                Customer   aCustomer = (Customer)Session["Customer"];
                aCustomer.Orders[0].OrderID = PaymentConfirmation;
                aCustomer = CartFunctions.setOrderId(aCustomer, PaymentConfirmation);
                // Add order to DB.

                da.addCustomer(aCustomer);
                da.addOrder(aCustomer);
                da.addOrderline(aCustomer);

                // Clear Order

                aCustomer = CartFunctions.clearOrder(aCustomer);
            }
            else
            {
                Response.Redirect("CheckoutError.aspx?" + retMsg);
            }
        }
    }
예제 #14
0
        public ActionResult Checkout(string userName, string sessionId)
        {
            DateTime refTime     = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            DateTime currentDate = DateTime.Now;

            long unixTime = (long)(currentDate - refTime).TotalSeconds;

            unixTime = (long)(currentDate - refTime).TotalSeconds;

            //Update purchase table
            //CheckoutFunctions.UpdatePurchaseTable(userName, unixTime);

            //Clear cart after check out
            CartFunctions.EmptyCart(userName);
            return(RedirectToAction("ViewPurchases", "History"));
        }
예제 #15
0
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            CartFunctions cartFunctions = null;

            if (controllerContext.HttpContext.Session != null)
            {
                cartFunctions = (CartFunctions)controllerContext.HttpContext.Session[sessions];
            }

            if (cartFunctions == null)
            {
                cartFunctions = new CartFunctions();
                if (controllerContext.HttpContext.Session != null)
                {
                    controllerContext.HttpContext.Session[sessions] = cartFunctions;
                }
            }
            return(cartFunctions);
        }
예제 #16
0
    //if row is deleted remove orderline
    protected void GridView1_RowDeleting(Object sender, GridViewDeleteEventArgs e)
    {
        Customer aCustomer = (Customer)Session["Customer"];
        int      index     = e.RowIndex;

        aCustomer = CartFunctions.removeItem(aCustomer, index);

        if (aCustomer.Orders[0].OrderLines.Count == 0)
        {
            HyperLink continueShop = new HyperLink();
            continueShop.NavigateUrl = "Shop.aspx";
            continueShop.Text        = "Back to the Shop";
            cartcontainer.InnerHtml  = "You have nothing in your cart" + " ";
            cartcontainer.Controls.Add(continueShop);
        }

        var query = from goods in aCustomer.Orders[0].OrderLines
                    select new
        {
            Name        = goods.Product.ProdName,
            Description = goods.Product.ProdDescription,
            Price       = goods.Product.ProdPrice,
            Qty         = goods.Quantity,
            Total       = "£" + Convert.ToString(goods.Quantity * goods.Product.ProdPrice),
            ProdImage   = goods.Product.ProdImage
        };

        subTotal     = CartFunctions.getSubTotal(aCustomer);
        cellSub.Text = "£" + Convert.ToString(subTotal);

        GridView1.DataSource = query;
        GridView1.DataBind();
        Session["Customer"] = aCustomer;

        Label lblCost = (Label)this.Master.FindControl("lblCost");

        lblCost.Text = CartFunctions.getSubTotal(aCustomer).ToString("C");

        Label lblItem = (Label)this.Master.FindControl("lblItems");

        lblItem.Text = CartFunctions.getNumItem(aCustomer).ToString() + " items";
    }
예제 #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //get id from query string if not empty
        if (Request.QueryString["id"] != null)
        {
            int            id = Convert.ToInt16(Request.QueryString["id"]);
            List <Product> p  = (List <Product>)Session["Products"];

            foreach (Product product in p)
            {
                //if the product in product list matches id display product information
                if (product.ProdID == id)
                {
                    lblPrice.Text         = "£" + Convert.ToString(product.ProdPrice);
                    lblProdTitle.Text     = product.ProdName;
                    imgProdImage.ImageUrl = product.ProdImage;
                    lblSubHeading.Text    = product.ProdDescription;
                    lblDescription.Text   = product.ProdDescriptionFull;

                    lblCategory.Text = CartFunctions.getCategory(product.ProdID);
                }
            }
        }
    }
예제 #18
0
    //check to see if customer has increased  order numher
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "AddItem")
        {
            // Retrieve the row index stored in the
            // CommandArgument property.
            int index = Convert.ToInt32(e.CommandArgument);

            // Retrieve the row that contains the button
            // from the Rows collection.
            GridViewRow row = GridView1.Rows[index];

            // Add code here to add the item to the shopping cart
            Customer aCustomer = (Customer)Session["Customer"];
            aCustomer.Orders[0].OrderLines[index].Quantity += 1;
            //display orderlines
            var query = from goods in aCustomer.Orders[0].OrderLines
                        select new
            {
                Name        = goods.Product.ProdName,
                Description = goods.Product.ProdDescription,
                Price       = goods.Product.ProdPrice,
                Qty         = goods.Quantity,
                Total       = "£" + Convert.ToString(goods.Quantity * goods.Product.ProdPrice),
                ProdImage   = goods.Product.ProdImage
            };

            subTotal       = CartFunctions.getSubTotal(aCustomer);
            cellSub.Text   = "£" + Convert.ToString(subTotal);
            total          = subTotal + shipping;
            cellTotal.Text = "£" + total;

            GridView1.DataSource = query;
            GridView1.DataBind();
            Session["Customer"] = aCustomer;

            Label lblCost = (Label)this.Master.FindControl("lblCost");
            lblCost.Text = CartFunctions.getSubTotal(aCustomer).ToString("C");

            Label lblItem = (Label)this.Master.FindControl("lblItems");
            lblItem.Text = CartFunctions.getNumItem(aCustomer).ToString() + " items";
        }

        //check to see if customer has decreased order numher
        if (e.CommandName == "RemoveItem")
        {
            // Retrieve the row index stored in the
            // CommandArgument property.
            int index = Convert.ToInt32(e.CommandArgument);

            // Retrieve the row that contains the button
            // from the Rows collection.
            GridViewRow row       = GridView1.Rows[index];
            Customer    aCustomer = (Customer)Session["Customer"];
            aCustomer.Orders[0].OrderLines[index].Quantity -= 1;
            //display orderlines
            if (aCustomer.Orders[0].OrderLines[index].Quantity == 0)
            {
                aCustomer = CartFunctions.removeItem(aCustomer, index);
                if (aCustomer.Orders[0].OrderLines.Count == 0)
                {
                    HyperLink continueShop = new HyperLink();
                    continueShop.NavigateUrl = "Shop.aspx";
                    continueShop.Text        = "Back to the Shop";
                    cartcontainer.InnerHtml  = "You have nothing in your cart" + " ";
                    cartcontainer.Controls.Add(continueShop);
                }
            }

            //display orderlines
            var query = from goods in aCustomer.Orders[0].OrderLines
                        select new
            {
                Name        = goods.Product.ProdName,
                Description = goods.Product.ProdDescription,
                Price       = "£" + goods.Product.ProdPrice,
                Qty         = goods.Quantity,
                Total       = "£" + Convert.ToString(goods.Quantity * goods.Product.ProdPrice),
                ProdImage   = goods.Product.ProdImage
            };

            subTotal       = CartFunctions.getSubTotal(aCustomer);
            cellSub.Text   = "£" + Convert.ToString(subTotal);
            total          = subTotal + shipping;
            cellTotal.Text = "£" + total;

            GridView1.DataSource = query;
            GridView1.DataBind();
            Session["Customer"] = aCustomer;

            Label lblCost = (Label)this.Master.FindControl("lblCost");
            lblCost.Text = CartFunctions.getSubTotal(aCustomer).ToString("C");

            Label lblItem = (Label)this.Master.FindControl("lblItems");
            lblItem.Text = CartFunctions.getNumItem(aCustomer).ToString() + " items";
        }
    }
예제 #19
0
        public void ProcessRequest(HttpContext context)
        {
            #region "Initialize"

            var strOut = "** No Action **";

            var paramCmd       = Utils.RequestQueryStringParam(context, "cmd");
            var itemId         = Utils.RequestQueryStringParam(context, "itemid");
            var ctlType        = Utils.RequestQueryStringParam(context, "ctltype");
            var idXref         = Utils.RequestQueryStringParam(context, "idxref");
            var xpathpdf       = Utils.RequestQueryStringParam(context, "pdf");
            var xpathref       = Utils.RequestQueryStringParam(context, "pdfref");
            var lang           = Utils.RequestQueryStringParam(context, "lang");
            var language       = Utils.RequestQueryStringParam(context, "language");
            var moduleId       = Utils.RequestQueryStringParam(context, "mid");
            var moduleKey      = Utils.RequestQueryStringParam(context, "mkey");
            var parentid       = Utils.RequestQueryStringParam(context, "parentid");
            var entryid        = Utils.RequestQueryStringParam(context, "entryid");
            var entryxid       = Utils.RequestQueryStringParam(context, "entryxid");
            var catid          = Utils.RequestQueryStringParam(context, "catid");
            var catxid         = Utils.RequestQueryStringParam(context, "catxid");
            var templatePrefix = Utils.RequestQueryStringParam(context, "tprefix");
            var value          = Utils.RequestQueryStringParam(context, "value");
            var itemListName   = Utils.RequestQueryStringParam(context, "listname");
            if (itemListName == "")
            {
                itemListName = "ItemList";
            }
            if (itemListName == "*")
            {
                itemListName = "ItemList";
            }

            #region "setup language"

            // because we are using a webservice the system current thread culture might not be set correctly,
            _uilang = NBrightBuyUtils.SetContextLangauge(context);
            var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);
            _editlang = NBrightBuyUtils.GetEditLang(ajaxInfo, _uilang);

            #endregion

            Logging.Debug($"XmlConnector called with: paramCmd='{paramCmd}', itemId='{itemId}', itemListName='{itemListName}'");

            #endregion

            try
            {
                #region "Do processing of command"

                if (paramCmd.StartsWith("client."))
                {
                    strOut = ClientFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("orderadmin_"))
                {
                    strOut = OrderFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("payment_"))
                {
                    strOut = PaymentFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("product_"))
                {
                    ProductFunctions.EntityTypeCode = "PRD";
                    strOut = ProductFunctions.ProcessCommand(paramCmd, context, _editlang);
                }
                else if (paramCmd.StartsWith("category_"))
                {
                    CategoryFunctions.EntityTypeCode = "CATEGORY";
                    strOut = CategoryFunctions.ProcessCommand(paramCmd, context, _editlang);
                }
                else if (paramCmd.StartsWith("property_"))
                {
                    PropertyFunctions.EntityTypeCode = "CATEGORY";
                    strOut = PropertyFunctions.ProcessCommand(paramCmd, context, _editlang);
                }
                else if (paramCmd.StartsWith("itemlist_"))
                {
                    strOut = ItemListsFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("addressadmin_"))
                {
                    strOut = AddressAdminFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("plugins_"))
                {
                    strOut = PluginFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("cart_"))
                {
                    strOut = CartFunctions.ProcessCommand(paramCmd, context);
                }
                else
                {
                    switch (paramCmd)
                    {
                    case "test":
                        strOut = "<root>" + UserController.Instance.GetCurrentUserInfo().Username + "</root>";
                        break;

                    case "setdata":
                        break;

                    case "deldata":
                        break;

                    case "getdata":
                        strOut = GetReturnData(context);
                        break;

                    case "fileupload":
                        if (NBrightBuyUtils.CheckRights())
                        {
                            strOut = FileUpload(context);
                        }
                        break;

                    case "fileclientupload":
                        if (StoreSettings.Current.GetBool("allowupload"))
                        {
                            strOut = FileUpload(context, itemId);
                        }
                        break;

                    case "docdownload":

                        var fname   = Utils.RequestQueryStringParam(context, "filename");
                        var filekey = Utils.RequestQueryStringParam(context, "key");
                        if (filekey != "")
                        {
                            var uData = new UserData();
                            if (uData.HasPurchasedDocByKey(filekey))
                            {
                                fname = uData.GetPurchasedFileName(filekey);
                            }
                            fname = StoreSettings.Current.FolderDocuments + "/" + fname;
                        }
                        if (fname != "")
                        {
                            strOut = fname;     // return this is error.
                            var downloadname = Utils.RequestQueryStringParam(context, "downloadname");
                            var fpath        = HttpContext.Current.Server.MapPath(fname);
                            if (downloadname == "")
                            {
                                downloadname = Path.GetFileName(fname);
                            }
                            try
                            {
                                Utils.ForceDocDownload(fpath, downloadname, context.Response);
                            }
                            catch (Exception ex)
                            {
                                // ignore, robots can cause error on thread abort.
                                //Exceptions.LogException(ex);
                                Logging.Debug($"XmlConnector.ProcessRequest exception for {paramCmd} which is ignored because bots tend to cause these on thread abort: {ex.Message}.");
                            }
                        }
                        break;

                    case "printproduct":
                        break;

                    case "renderpostdata":
                        strOut = RenderPostData(context);
                        break;

                    case "getsettings":
                        strOut = GetSettings(context);
                        break;

                    case "savesettings":
                        if (NBrightBuyUtils.CheckRights())
                        {
                            strOut = SaveSettings(context);
                        }
                        break;

                    case "updateprofile":
                        strOut = UpdateProfile(context);
                        break;

                    case "dosearch":
                        strOut = DoSearch(context);
                        break;

                    case "resetsearch":
                        strOut = ResetSearch(context);
                        break;

                    case "orderby":
                        strOut = DoOrderBy(context);
                        break;

                    case "renderthemefolders":
                        strOut = RenderThemeFolders(context);
                        break;
                    }
                }

                if (strOut == "** No Action **")
                {
                    var pluginData = new PluginData(PortalSettings.Current.PortalId);
                    var provList   = pluginData.GetAjaxProviders();
                    foreach (var d in provList)
                    {
                        if (paramCmd.ToLower().StartsWith(d.Key.ToLower() + "_") || paramCmd.ToLower().StartsWith("cmd" + d.Key.ToLower() + "_"))
                        {
                            var ajaxprov = AjaxInterface.Instance(d.Key);
                            if (ajaxprov != null)
                            {
                                strOut = ajaxprov.ProcessCommand(paramCmd, context, _editlang);
                            }
                        }
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                strOut = ex.ToString();
                Logging.LogException(ex);
                //Exceptions.LogException(ex);
            }


            #region "return results"

            //send back xml as plain text
            context.Response.Clear();
            context.Response.ContentType = "text/plain";
            context.Response.Write(strOut);
            context.Response.End();

            #endregion
        }
예제 #20
0
 public CartFunctionsTests()
 {
     _function = new CartFunctions(_client.Object, _authService.Object);
 }
예제 #21
0
    protected void Page_Load(object sender, EventArgs e)
    {
        double subTotal = 0;
        double total    = 0;
        double shipping = 00;

        if (!IsPostBack)
        {
            NVPAPICaller payPalCaller = new NVPAPICaller();

            string retMsg   = "";
            string token    = "";
            string PayerID  = "";
            string foreName = "";
            string surName  = "";
            string email    = "";
            string address  = "";
            string postcode = "";
            string town     = "";

            NVPCodec decoder = new NVPCodec();
            token = Session["token"].ToString();

            bool ret = payPalCaller.GetCheckoutDetails(token, ref PayerID, ref decoder, ref retMsg);
            if (ret)
            {
                //get user information from papal
                Session["payerId"] = PayerID;

                foreName = decoder["FIRSTNAME"].ToString();
                surName  = decoder["LASTNAME"].ToString();
                address  = decoder["SHIPTOSTREET"].ToString();
                town     = decoder["SHIPTOCITY"].ToString();
                postcode = decoder["SHIPTOZIP"].ToString();
                email    = decoder["EMAIL"].ToString();

                //display user information
                lblFore.Text     = foreName;
                lblSur.Text      = surName;
                lblCity.Text     = town;
                lblEmail.Text    = email;
                lblPostCode.Text = postcode;
                lblAddress.Text  = address;


                //set customer object with information from paypal
                Customer aCustomer = (Customer)Session["Customer"];
                aCustomer.CityAddress   = town;
                aCustomer.Email         = email;
                aCustomer.FName         = foreName;
                aCustomer.SName         = surName;
                aCustomer.StreetAddress = address;
                aCustomer.PostCode      = postcode;


                // Verify total payment amount as set on CheckoutStart.aspx.
                try
                {
                    decimal paymentAmountOnCheckout = Convert.ToDecimal(Session["payment_amt"].ToString());
                    decimal paymentAmoutFromPayPal  = Convert.ToDecimal(decoder["AMT"].ToString());
                    shipping = Convert.ToDouble(decoder["SHIPPINGAMT"].ToString());
                    if (paymentAmountOnCheckout != paymentAmoutFromPayPal)
                    {
                        Response.Redirect("CheckoutError.aspx?" + "Desc=Amount%20total%20mismatch.");
                    }
                }
                catch (Exception)
                {
                    Response.Redirect("CheckoutError.aspx?" + "Desc=Amount%20total%20mismatch.");
                }

                // Display Order information.

                var query = from goods in aCustomer.Orders[0].OrderLines
                            select new
                {
                    Name        = goods.Product.ProdName,
                    Description = goods.Product.ProdDescription,
                    Price       = goods.Product.ProdPrice,
                    Qty         = goods.Quantity,
                    Total       = "£" + Convert.ToString(goods.Quantity * goods.Product.ProdPrice),
                    ProdImage   = goods.Product.ProdImage
                };


                GridView1.DataSource = query;
                GridView1.DataBind();

                subTotal = CartFunctions.getSubTotal(aCustomer);

                cellSub.Text      = "£" + Convert.ToString(subTotal);
                total             = subTotal + shipping;
                cellTotal.Text    = "£" + total;
                cellShipping.Text = shipping.ToString();
            }
            else
            {
                Response.Redirect("CheckoutError.aspx?" + retMsg);
            }
        }
    }
예제 #22
0
        public void ProcessRequest(HttpContext context)
        {
            #region "Initialize"

            var strOut = "** No Action **";

            var paramCmd       = Utils.RequestQueryStringParam(context, "cmd");
            var itemId         = Utils.RequestQueryStringParam(context, "itemid");
            var ctlType        = Utils.RequestQueryStringParam(context, "ctltype");
            var idXref         = Utils.RequestQueryStringParam(context, "idxref");
            var xpathpdf       = Utils.RequestQueryStringParam(context, "pdf");
            var xpathref       = Utils.RequestQueryStringParam(context, "pdfref");
            var lang           = Utils.RequestQueryStringParam(context, "lang");
            var language       = Utils.RequestQueryStringParam(context, "language");
            var moduleId       = Utils.RequestQueryStringParam(context, "mid");
            var moduleKey      = Utils.RequestQueryStringParam(context, "mkey");
            var parentid       = Utils.RequestQueryStringParam(context, "parentid");
            var entryid        = Utils.RequestQueryStringParam(context, "entryid");
            var entryxid       = Utils.RequestQueryStringParam(context, "entryxid");
            var catid          = Utils.RequestQueryStringParam(context, "catid");
            var catxid         = Utils.RequestQueryStringParam(context, "catxid");
            var templatePrefix = Utils.RequestQueryStringParam(context, "tprefix");
            var value          = Utils.RequestQueryStringParam(context, "value");
            var itemListName   = Utils.RequestQueryStringParam(context, "listname");
            if (itemListName == "")
            {
                itemListName = "ItemList";
            }
            if (itemListName == "*")
            {
                itemListName = "ItemList";
            }

            #region "setup language"

            // because we are using a webservice the system current thread culture might not be set correctly,
            NBrightBuyUtils.SetContextLangauge(context);
            var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);
            _editlang = NBrightBuyUtils.GetEditLang(ajaxInfo, Utils.GetCurrentCulture());

            #endregion

            Logging.Debug($"XmlConnector called with: paramCmd='{paramCmd}', itemId='{itemId}', itemListName='{itemListName}'");

            #endregion

            try
            {
                #region "Do processing of command"

                if (paramCmd.StartsWith("client."))
                {
                    strOut = ClientFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("orderadmin_"))
                {
                    strOut = OrderFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("payment_"))
                {
                    strOut = PaymentFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("product_"))
                {
                    var productFunctions = new ProductFunctions();
                    strOut = productFunctions.ProcessCommand(paramCmd, context, _editlang);
                }
                else if (paramCmd.StartsWith("category_"))
                {
                    var categoryFunctions = new CategoryFunctions();
                    strOut = categoryFunctions.ProcessCommand(paramCmd, context, _editlang);
                }
                else if (paramCmd.StartsWith("property_"))
                {
                    var propertyFunctions = new PropertyFunctions();
                    strOut = propertyFunctions.ProcessCommand(paramCmd, context, _editlang);
                }
                else if (paramCmd.StartsWith("itemlist_"))
                {
                    strOut = ItemListsFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("addressadmin_"))
                {
                    strOut = AddressAdminFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("plugins_"))
                {
                    strOut = PluginFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("cart_"))
                {
                    strOut = CartFunctions.ProcessCommand(paramCmd, context);
                }
                else
                {
                    switch (paramCmd)
                    {
                    case "test":
                        strOut = "<root>" + UserController.Instance.GetCurrentUserInfo().Username + "</root>";
                        break;

                    case "setdata":
                        break;

                    case "deldata":
                        break;

                    case "getdata":
                        strOut = GetReturnData(context);
                        break;

                    case "fileupload":
                        if (NBrightBuyUtils.CheckRights())
                        {
                            strOut = FileUpload(context);
                        }
                        break;

                    case "fileclientupload":
                        if (StoreSettings.Current.GetBool("allowupload"))
                        {
                            strOut = FileUpload(context, itemId);
                        }
                        break;

                    case "docdownload":
                        strOut = DownloadSystemFile(paramCmd, context);
                        break;

                    case "printproduct":
                        break;

                    case "renderpostdata":
                        strOut = RenderPostData(context);
                        break;

                    case "getsettings":
                        strOut = GetSettings(context);
                        break;

                    case "savesettings":
                        if (NBrightBuyUtils.CheckRights())
                        {
                            strOut = SaveSettings(context);
                        }
                        break;

                    case "updateprofile":
                        strOut = UpdateProfile(context);
                        break;

                    case "dosearch":
                        strOut = DoSearch(context);
                        break;

                    case "resetsearch":
                        strOut = ResetSearch(context);
                        break;

                    case "orderby":
                        strOut = DoOrderBy(context);
                        break;

                    case "renderthemefolders":
                        strOut = RenderThemeFolders(context);
                        break;
                    }
                }

                if (strOut == "** No Action **")
                {
                    var ajaxprovider = ajaxInfo.GetXmlProperty("genxml/hidden/ajaxprovider");
                    if (ajaxprovider == "")
                    {
                        ajaxprovider = Utils.RequestQueryStringParam(context, "ajaxprovider");
                    }

                    var pluginData = new PluginData(PortalSettings.Current.PortalId);
                    var provList   = pluginData.GetAjaxProviders();
                    if (ajaxprovider != "")
                    {
                        strOut = "Ajax Provider not found: " + ajaxprovider;
                        if (provList.ContainsKey(ajaxprovider))
                        {
                            var ajaxprov = AjaxInterface.Instance(ajaxprovider);
                            if (ajaxprov != null)
                            {
                                strOut = ajaxprov.ProcessCommand(paramCmd, context, _editlang);
                            }
                        }
                    }
                    else
                    {
                        foreach (var d in provList)
                        {
                            if (paramCmd.ToLower().StartsWith(d.Key.ToLower() + "_") || paramCmd.ToLower().StartsWith("cmd" + d.Key.ToLower() + "_"))
                            {
                                var ajaxprov = AjaxInterface.Instance(d.Key);
                                if (ajaxprov != null)
                                {
                                    strOut = ajaxprov.ProcessCommand(paramCmd, context, _editlang);
                                }
                            }
                        }
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                strOut = ex.ToString();
                Logging.LogException(ex);
                //Exceptions.LogException(ex);
            }


            #region "return results"

            //send back xml as plain text
            context.Response.Clear();
            context.Response.ContentType = "text/plain";
            context.Response.Write(strOut);
            context.Response.End();

            #endregion
        }
예제 #23
0
 public PartialViewResult OrderValue(CartFunctions cartFunctions)
 {
     return(PartialView(cartFunctions));
 }
예제 #24
0
 public PartialViewResult CartNavbar(CartFunctions cartFunctions)
 {
     return(PartialView(cartFunctions));
 }
예제 #25
0
 public ViewResult CartSummary(CartFunctions cartFunctions, string url)
 {
     return(View(new CartContents {
         Url = url, cartFunctions = cartFunctions,
     }));
 }