public List <CartItem> UpdateCartItems() { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { String cartId = usersShoppingCart.GetCartId(); ShoppingCartActions.ShoppingCartUpdates[] cartUpdates = new ShoppingCartActions.ShoppingCartUpdates[CartList.Rows.Count]; for (int i = 0; i < CartList.Rows.Count; i++) { IOrderedDictionary rowValues = new OrderedDictionary(); rowValues = GetValues(CartList.Rows[i]); cartUpdates[i].ProductId = Convert.ToInt32(rowValues["ProductID"]); CheckBox cbRemove = new CheckBox(); cbRemove = (CheckBox)CartList.Rows[i].FindControl("Remove"); cartUpdates[i].RemoveItem = cbRemove.Checked; TextBox quantityTextBox = new TextBox(); quantityTextBox = (TextBox)CartList.Rows[i].FindControl("PurchaseQuantity"); cartUpdates[i].PurchaseQuantity = Convert.ToInt16(quantityTextBox.Text.ToString()); } usersShoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates); CartList.DataBind(); lblTotal.Text = String.Format("{0:c}", usersShoppingCart.GetTotal()); return(usersShoppingCart.GetCartItems()); } }
public ActionResult AddItemQuantity() { string rawId = Request.QueryString["ProductId"]; int productId; if (!String.IsNullOrEmpty(rawId) && int.TryParse(rawId, out productId)) { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { String cartId = usersShoppingCart.GetCartId(); var allItems = usersShoppingCart.GetCartItems(); int currentQuantity = 0; foreach (var item in allItems) { if (Convert.ToInt16(rawId) == item.ProductId) { currentQuantity = item.Quantity; } } currentQuantity += 1; usersShoppingCart.UpdateItem(cartId, Convert.ToInt16(rawId), currentQuantity); } } else { Debug.Fail("ERROR : We should never get to /ShoppingCart/AddItemQuantity without a ProductId."); throw new Exception("ERROR : It is illegal to load /ShoppingCart/AddItemQuantity without setting a ProductId."); } return(RedirectToAction("Index")); }
//UpdatecartItems Method public List <CartItem> UpdateCartItems() { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { String cartId = usersShoppingCart.GetCartId(); ShoppingCartActions.ShoppingCartUpdates[] cartUpdates = new ShoppingCartActions.ShoppingCartUpdates[CartList.Rows.Count]; for (int i = 0; i < CartList.Rows.Count; i++) { //The amount of products in the cart. IOrderedDictionary rowValues = new OrderedDictionary(); rowValues = GetValues(CartList.Rows[i]); cartUpdates[i].ProductId = Convert.ToInt32(rowValues["ProductID"]); //This the checkbox to tick to remove a product. CheckBox cbRemove = new CheckBox(); cbRemove = (CheckBox)CartList.Rows[i].FindControl("Remove"); cartUpdates[i].RemoveItem = cbRemove.Checked; //This is the textbox to change the quantity. TextBox quantityTextBox = new TextBox(); quantityTextBox = (TextBox)CartList.Rows[i].FindControl("PurchaseQuantity"); cartUpdates[i].PurchaseQuantity = Convert.ToInt16(quantityTextBox.Text.ToString()); } //This updates the total for all prdoucts in the cart using the GetTotal method. usersShoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates); CartList.DataBind(); lblTotal.Text = String.Format("{0:c}", usersShoppingCart.GetTotal()); return(usersShoppingCart.GetCartItems()); } }
protected void shippingDetails_Click(object sender, EventArgs e) { var cart = new ShoppingCartActions(); var items = cart.GetCartItems(); Order order = new Order { FirstName = FirstName.Text, OrderDate = DateTime.Now, LastName = LastName.Text, Address = Address.Text, City = City.Text, Country = Country.Text, PostalCode = PostalCode.Text, State = State.Text, Email = Email.Text, HasBeenShipped = true, Phone = Phone.Text, Total = cart.GetTotal() }; db.Orders.Add(order); db.SaveChanges(); order.OrderDetails = new List <OrderDetail>(); foreach (var item in items) { var details = new OrderDetail { OrderId = order.OrderId, ProductId = item.ProductId, Quantity = item.Quantity, UnitPrice = db.Products.Find(item.ProductId).UnitPrice, Username = order.Email }; order.OrderDetails.Add(details); } db.Entry(order).State = EntityState.Modified; db.SaveChanges(); cart.EmptyCart(); Response.Redirect("~/Checkout/CheckoutComplete.aspx"); }
protected void CheckoutBtn_Click(object sender, EventArgs e) { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { string products = ""; string prices = ""; string quantities = ""; foreach (var product in usersShoppingCart.GetCartItems()) { var name = product.Product.ProductName; var price = product.Product.UnitPrice; var quantity = product.Quantity; quantities = quantities + quantity + ","; prices = prices + price + ","; products = products + name + ","; } Session["product_names"] = products; Session["product_prices"] = prices; Session["product_quantities"] = quantities; Session["payment_amt"] = usersShoppingCart.GetTotal(); } Response.Redirect("Checkout/CheckoutStart.aspx"); }
//update cart item with db private List <CartItem> UpdateCartItems() { using (ShoppingCartActions shopaction = new ShoppingCartActions()) { string cartId = shopaction.GetCartId().ToString(); ShoppingCartActions.ShoppingCartUpdates[] cartUpdates = new ShoppingCartActions.ShoppingCartUpdates[CartList.Rows.Count]; //collect item in cart to update list for (int i = 0; i < CartList.Rows.Count; i++) { IOrderedDictionary rowValues = GetValues(CartList.Rows[i]); cartUpdates[i].ProductId = Convert.ToInt32(rowValues["ProductID"]); CheckBox cbRm = CartList.Rows[i].FindControl("Remove") as CheckBox; cartUpdates[i].RemoveItem = cbRm.Checked; TextBox qnt = CartList.Rows[i].FindControl("PurchaseQuantity") as TextBox; cartUpdates[i].PurchaseQuantity = Convert.ToInt16(qnt.Text); } shopaction.UpdateShoppingCartDatabase(cartId, cartUpdates); CartList.DataBind(); lblTotal.Text = string.Format("{0:c}", shopaction.GetTotal()); return(shopaction.GetCartItems()); } }
private List <CartItem> UpdateCartItems() { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { ShoppinCartUpdates[] cartUpdates = new ShoppinCartUpdates[CartList.Rows.Count]; for (int i = 0; i < CartList.Rows.Count; i++) { IOrderedDictionary rowValues = new OrderedDictionary(); rowValues = GetValues(CartList.Rows[i]); cartUpdates[i].produtoId = Convert.ToInt32(rowValues["ProductId"]); CheckBox cbRemove = new CheckBox(); cbRemove = (CheckBox)CartList.Rows[i].FindControl("Remove"); cartUpdates[i].isRemovedItem = cbRemove.Checked; TextBox TbQuantity = new TextBox(); TbQuantity = (TextBox)CartList.Rows[i].FindControl("PurchaseQuantity"); cartUpdates[i].purchaseQuantity = Convert.ToInt32(TbQuantity.Text); } usersShoppingCart.UpdateShoppingCartDatabase(cartUpdates); CartList.DataBind(); lblTotal.Text = String.Format("{0:c}", usersShoppingCart.GetTotal()); return(usersShoppingCart.GetCartItems().ToList()); } }
public List <CartItem> UpdateCartItems() { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { String cartId = usersShoppingCart.GetCartId(); List <ShoppingCartActions.ShoppingCartUpdates> cartUpdates = new List <ShoppingCartActions.ShoppingCartUpdates>(); foreach (GridViewRow row in CartList.Rows) { IOrderedDictionary rowValues = new OrderedDictionary(); rowValues = GetValues(row); var ControlCheckbox = (CheckBox)row.FindControl("Remove"); var TextBox = (TextBox)row.FindControl("PurchaseQuantity"); ShoppingCartActions.ShoppingCartUpdates cartUpdate = new ShoppingCartActions.ShoppingCartUpdates { ProductId = Convert.ToInt32(rowValues["ProductID"]), RemoveItem = ControlCheckbox.Checked, PurchaseQuantity = Convert.ToInt16(TextBox.Text.ToString()) }; cartUpdates.Add(cartUpdate); } usersShoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates); CartList.DataBind(); lblTotal.Text = String.Format("{0:c}", usersShoppingCart.GetTotal()); return(usersShoppingCart.GetCartItems()); } }
public List <CartItem> GetShoppingCartItems() { ShoppingCartActions actions = new ShoppingCartActions(); var items = actions.GetCartItems(); return(items); }
public List <CartItem> UpdateRepeats() { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { String cartId = usersShoppingCart.GetCartId(); ShoppingCartActions.ShoppingCartUpdates[] cartUpdates = new ShoppingCartActions.ShoppingCartUpdates[CartList.Rows.Count]; for (int i = 0; i < CartList.Rows.Count; i++) { IOrderedDictionary rowValues = new OrderedDictionary(); rowValues = GetValues(CartList.Rows[i]); cartUpdates[i].ProductId = Convert.ToInt32(rowValues["ProductID"]); //CheckBox cbRemove = new CheckBox(); //cbRemove = (CheckBox)CartList.Rows[i].FindControl("Remove"); //cartUpdates[i].RemoveItem = cbRemove.Checked; // DropDownList selectedRepeat = new DropDownList(); // selectedRepeat = //(DropDownList)CartList.Rows[i].FindControl("Repeat"); // cartUpdates[i].RepeatOrder = selectedRepeat.SelectedValue; /* HERE */ //DropDownList selectedRepeat = new DropDownList(); DropDownList selectedRepeat = (DropDownList)CartList.Rows[i].FindControl("RepeatOrder"); cartUpdates[i].RepeatOrder = selectedRepeat.SelectedValue; /* HERE */ } usersShoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates); CartList.DataBind(); //lblTotal.Text = String.Format("{0:c}", usersShoppingCart.GetTotal()); return(usersShoppingCart.GetCartItems()); } }
public List <CartItem> GetShoppingCartItems() { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { return(usersShoppingCart.GetCartItems().ToList()); } }
public bool ShortcutExpressCheckout(string amt, ref string token, ref string retMsg) { if (bSandbox) { pEndPointURL = pEndPointURL_SB; host = host_SB; } string returnURL = "http://localhost:49252/Checkout/CheckoutReview.aspx"; string cancelURL = "http://localhost:49252/Checkout/CheckoutCancel.aspx"; NVPCodec encoder = new NVPCodec(); encoder["METHOD"] = "SetExpressCheckout"; encoder["RETURNURL"] = returnURL; encoder["CANCELURL"] = cancelURL; encoder["BRANDNAME"] = "Kidsmeer toys e-commerce"; encoder["PAYMENTREQUEST_0_AMT"] = amt; encoder["PAYMENTREQUEST_0_ITEMAMT"] = amt; encoder["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale"; encoder["PAYMENTREQUEST_0_CURRENCYCODE"] = "USD"; // Get the Shopping Cart Products using (ShoppingCartActions myCartOrders = new ShoppingCartActions()) { List <CartItem> myOrderList = myCartOrders.GetCartItems(); for (int i = 0; i < myOrderList.Count; i++) { encoder["L_PAYMENTREQUEST_0_NAME" + i] = myOrderList[i].Product.ProductName.ToString(); encoder["L_PAYMENTREQUEST_0_AMT" + i] = myOrderList[i].Product.UnitPrice.ToString(); encoder["L_PAYMENTREQUEST_0_QTY" + i] = myOrderList[i].Quantity.ToString(); } } string pStrrequestforNvp = encoder.Encode(); string pStresponsenvp = HttpCall(pStrrequestforNvp); NVPCodec decoder = new NVPCodec(); decoder.Decode(pStresponsenvp); string strAck = decoder["ACK"].ToLower(); if (strAck != null && (strAck == "success" || strAck == "successwithwarning")) { token = decoder["TOKEN"]; string ECURL = "https://" + host + "/cgi-bin/webscr?cmd=_express-checkout" + "&token=" + token; retMsg = ECURL; return(true); } else { retMsg = "ErrorCode=" + decoder["L_ERRORCODE0"] + "&" + "Desc=" + decoder["L_SHORTMESSAGE0"] + "&" + "Desc2=" + decoder["L_LONGMESSAGE0"]; return(false); } }
public async Task GetShoppingCartItems() { ShoppingCartActions actions = new ShoppingCartActions(); var cartItems = await actions.GetCartItems(); CartList.DataSource = cartItems; CartList.DataBind(); }
protected void SendCartDetails() { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { Session["payment_amt"] = usersShoppingCart.GetTotal(); Session["cart_items"] = usersShoppingCart.GetCartItems(); } }
public void CheckoutBtn_Click(object sender, EventArgs e) { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { Session["payment_amt"] = usersShoppingCart.GetTotal(); Session["Cart"] = usersShoppingCart.GetCartItems(); } Response.Redirect("Checkout/shippingDetails.aspx"); }
/// <summary> /// Returns all the items in the cart. Used to populate the GridView rows /// </summary> /// <returns></returns> public List <CartItem> GetShoppingCartItems() { ShoppingCartActions actions = new ShoppingCartActions(); //Validate the cart items foreach (var item in actions.GetCartItems()) { if (item.Product.ProductName.Equals("Bananas", StringComparison.Ordinal) && item.Quantity > 10) { item.Quantity = 10; lblWarning.ForeColor = Color.Red; lblWarning.Text = "Warning! You can only order a maximum of 10 Bananas. Net Total Updated."; } } return(actions.GetCartItems()); }
public List<cartitem> Getcoursecartitems() { // if (Session["a"] != null) // { ShoppingCartActions actions = new ShoppingCartActions(); return actions.GetCartItems(); // } // else // return null; }
public List <CartItem> UpdateCartItems() { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { String cartId = usersShoppingCart.GetCartId(); ShoppingCartActions.ShoppingCartUpdates[] cartUpdates = new ShoppingCartActions.ShoppingCartUpdates[CartList.Rows.Count]; for (int i = 0; i < CartList.Rows.Count; i++) { IOrderedDictionary rowValues = new OrderedDictionary(); rowValues = GetValues(CartList.Rows[i]); cartUpdates[i].LivroId = Convert.ToInt32(rowValues["livro_id"]); CheckBox cbRemove = new CheckBox(); cbRemove = (CheckBox)CartList.Rows[i].FindControl("Remover"); cartUpdates[i].RemoverItem = cbRemove.Checked; int quantidadeAnterior = GetShoppingCartItems().Cast <CartItem>().ElementAt(i).quantidade; Estoque estoque = commands["CONSULTAR"].execute(new Estoque() { Livro = new Dominio.Livro.Livro() { ID = cartUpdates[i].LivroId } }).Entidades.Cast <Estoque>().ElementAt(0); TextBox quantityTextBox = new TextBox(); quantityTextBox = (TextBox)CartList.Rows[i].FindControl("PurchaseQuantity"); if (estoque.Qtde < Convert.ToInt32(quantityTextBox.Text)) { cartUpdates[i].PurchaseQuantity = quantidadeAnterior; lblResultadoCarrinho.Text = "Quantidade em estoque do livro " + estoque.Livro.Titulo + " é de " + estoque.Qtde + " unidade(s)"; lblResultadoCarrinho.Visible = true; } else { cartUpdates[i].PurchaseQuantity = Convert.ToInt16(quantityTextBox.Text.ToString()); lblResultadoCarrinho.Text = ""; lblResultadoCarrinho.Visible = false; } } usersShoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates); CartList.DataBind(); lblSubtotal.Text = String.Format("{0:c}", usersShoppingCart.GetTotal()); return(usersShoppingCart.GetCartItems()); } }
// GET: Cart public ActionResult Index() { var cartId = new Helpers.CartHelpers().GetCartId(); var vm = new CartViewModel(); using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions(cartId)) { var shoppingCartItems = usersShoppingCart.GetCartItems(); var cartItemsVM = Mapper.Map <List <CartItemViewModel> >(shoppingCartItems); vm.CartItems = cartItemsVM; vm.ItemsTotal = usersShoppingCart.GetCount(); vm.OrderTotal = usersShoppingCart.GetTotal(); } //var shoppingCartItems = db.ShoppingCartItems.Include(c => c.Product); return(View(vm)); }
public List<cartitem> delteCartItems() { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { String cartId = usersShoppingCart.GetCartId(); for (int i = 0; i < usersShoppingCart.GetTotal(); i++) { usersShoppingCart.DeleteShoppingCartDatabase(cartId); } // lblTotal.Text = "0"; return usersShoppingCart.GetCartItems(); } }
// GET: Cart public ActionResult Index() { var cartId = new Helpers.CartHelpers().GetCartId(HttpContext); var vm = new CartModel(); var usersShoppingCart = new ShoppingCartActions(_db, cartId); var shoppingCartItems = usersShoppingCart.GetCartItems(); var cartItemsVM = _mapper.Map <List <CartItemModel> >(shoppingCartItems); vm.CartItems = cartItemsVM; vm.ItemsTotal = usersShoppingCart.GetCount(); vm.OrderTotal = usersShoppingCart.GetTotal(); //var shoppingCartItems = db.ShoppingCartItems.Include(c => c.Product); return(View(vm)); }
// GET: Checkout public ActionResult Index() { var vm = new CheckoutModel(); using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions(cartId, items, categories)) { var shoppingCartItems = usersShoppingCart.GetCartItems(); var cartItemsVM = Mapper.Map <List <CartItemModel> >(shoppingCartItems); vm.CartItems = cartItemsVM; vm.OrderTotal = usersShoppingCart.GetTotal(); vm.ItemsTotal = usersShoppingCart.GetCount(); } var user = (User)Session["User"]; var email = "*****@*****.**"; if (user != null && !string.IsNullOrWhiteSpace(user.Email)) { email = user.Email; } // To make filling out the form faster for demo purposes, pre-fill the values: vm.Order = new OrderModel { // Important! Keep this property here! Total = vm.OrderTotal, // Prefill properties for convenience: FirstName = "Bob", LastName = "Loblaw", Address = "1313 Mockingbird Lane", City = "Virginia Beach", State = "VA", PostalCode = "23456", Country = "United States", Email = email, NameOnCard = "Bob Loblaw", CreditCardType = "Visa", CreditCardNumber = "4111111111111111", ExpirationDate = "12/25", CCV = "987", SMSOptIn = true }; return(View(vm)); }
/**When user clicks "purchase", iterate through all items in customer's shopping cart and * send product id, product name, and unit price to shopping cart action file to create * 'purchased' event in Cosmos DB**/ protected void CheckoutBtn_Click(object sender, EventArgs e) { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { foreach (var item in usersShoppingCart.GetCartItems()) { int productId = item.ProductId; string productName = item.Product.ProductName; double unitPrice = Convert.ToDouble(item.Product.UnitPrice); for (int k = 0; k < item.Quantity; k++) { usersShoppingCart.PurchaseProduct(productId, productName, unitPrice); } } usersShoppingCart.EmptyCart(); /**Redirect user to page that thanks them for their purchase**/ Response.Redirect("~/PurchasePage.aspx"); } }
public List <CartItem> UpdateCartItems() { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { String cartId = usersShoppingCart.GetCartId(); ShoppingCartActions.ShoppingCartUpdates[] cartUpdates = new ShoppingCartActions.ShoppingCartUpdates[CartList.Rows.Count]; for (int i = 0; i < CartList.Rows.Count; i++) { IOrderedDictionary rowValues = new OrderedDictionary(); rowValues = GetValues(CartList.Rows[i]); cartUpdates[i].ProductId = Convert.ToInt32(rowValues["ProductID"]); CheckBox cbRemove = new CheckBox(); cbRemove = (CheckBox)CartList.Rows[i].FindControl("Remove"); cartUpdates[i].RemoveItem = cbRemove.Checked; TextBox priceTextBox = new TextBox(); priceTextBox = (TextBox)CartList.Rows[i].FindControl("PriceBx"); cartUpdates[i].PriceBx = Convert.ToDecimal(priceTextBox.Text.ToString()); //cartUpdates[i].ItemPrice = Convert.ToInt32(rowValues["OriginalPrice"]); TextBox quantityTextBox = new TextBox(); quantityTextBox = (TextBox)CartList.Rows[i].FindControl("PurchaseQuantity"); cartUpdates[i].PurchaseQuantity = Convert.ToInt16(quantityTextBox.Text.ToString()); } usersShoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates); CartList.DataBind(); //GetTotal() suppose to execute after UpdateShoppingCartDatabase string x = String.Format("{0:c}", usersShoppingCart.GetTotal()); if (x != "$0.00") { lblTotal.Text = x; } else { lblTotal.Text = ""; } return(usersShoppingCart.GetCartItems()); } }
// GET: CartItems public ActionResult Index() { ShoppingCartActions actions = new ShoppingCartActions(); using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { decimal cartTotal = 0; cartTotal = usersShoppingCart.GetTotal(); if (cartTotal > 0) { // Display Total. ViewBag.Total = cartTotal; } else { ViewBag.Total = "0"; } } return(View(actions.GetCartItems())); }
public ActionResult Purchase() { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { if (usersShoppingCart.GetCartItems().Count != 0 && this.User.Identity.IsAuthenticated) { ApplicationUser user = System.Web.HttpContext.Current.GetOwinContext() .GetUserManager <ApplicationUserManager>() .FindById(System.Web.HttpContext.Current.User.Identity.GetUserId()); ViewBag.FirstName = user.FirstName; ViewBag.LastName = user.LastName; ViewBag.Address = user.Address; usersShoppingCart.EmptyCart(); return(View()); } else { return(RedirectToAction("Index", "Home")); } } }
// GET: Checkout public ActionResult Index() { var vm = new CheckoutViewModel(); using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions(cartId)) { var shoppingCartItems = usersShoppingCart.GetCartItems(); var cartItemsVM = Mapper.Map <List <CartItemViewModel> >(shoppingCartItems); vm.CartItems = cartItemsVM; vm.OrderTotal = usersShoppingCart.GetTotal(); vm.ItemsTotal = usersShoppingCart.GetCount(); } // To make filling out the form faster for demo purposes, pre-fill the values: vm.Order = new OrderViewModel { // Important! Keep this property here! Total = vm.OrderTotal, // Prefill properties for convenience: FirstName = "Bob", LastName = "Loblaw", Address = "1313 Mockingbird Lane", City = "Virginia Beach", State = "VA", PostalCode = "23456", Country = "United States", Email = "*****@*****.**", NameOnCard = "Bob Loblaw", CreditCardType = "Visa", CreditCardNumber = "4111111111111111", ExpirationDate = "12/20", CCV = "987", SMSOptIn = true }; return(View(vm)); }
protected void PlaceOrderBtn_Click(object sender, EventArgs e) { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { Session["payment_amt"] = usersShoppingCart.GetTotal(); List <CartItem> MyCart = usersShoppingCart.GetCartItems(); //Place an order AddOrder(PaymentBox.Text, PaymentDateBox.Text, CommentBox.Text, MyCart); RemoveCartItems(); } new Emailer().SendEmail("*****@*****.**", "*****@*****.**", "FrontierAg New Order ", "Login to the website to see order details"); //new Emailer().SendEmail("*****@*****.**", "*****@*****.**", "FrontierAg New Order ", "Login to the website to see order details"); //new Emailer().SendEmail("*****@*****.**", "*****@*****.**", "FrontierAg New Order ", "Login to the website to see order details"); //new Emailer().SendEmail("*****@*****.**", "*****@*****.**", "FrontierAg New Order ", "Login to the website to see order details"); //new Emailer().SendEmail("*****@*****.**", "*****@*****.**", "FrontierAg New Order ", "Login to the website to see order details"); //new Emailer().SendEmail("[email protected] ", "*****@*****.**", "FrontierAg New Order ", "Login to the website to see order details"); Response.Redirect("~/Checkout/CheckoutComplete.aspx"); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { NVPAPICaller payPalCaller = new NVPAPICaller(); string retMsg = ""; string token = ""; string PayerID = ""; NVPCodec decoder = new NVPCodec(); token = Session["token"].ToString(); bool ret = payPalCaller.GetCheckoutDetails(token, ref PayerID, ref decoder, ref retMsg); if (ret) { Session["payerId"] = PayerID; var myOrder = new Order(); myOrder.OrderDate = Convert.ToDateTime(decoder["TIMESTAMP"].ToString()); myOrder.Username = User.Identity.Name; myOrder.FirstName = decoder["FIRSTNAME"].ToString(); myOrder.LastName = decoder["LASTNAME"].ToString(); myOrder.Address = decoder["SHIPTOSTREET"].ToString(); myOrder.City = decoder["SHIPTOCITY"].ToString(); myOrder.State = decoder["SHIPTOSTATE"].ToString(); myOrder.PostalCode = decoder["SHIPTOZIP"].ToString(); myOrder.Country = decoder["SHIPTOCOUNTRYCODE"].ToString(); myOrder.Email = decoder["EMAIL"].ToString(); myOrder.Total = Convert.ToDecimal(decoder["AMT"].ToString()); // 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()); if (paymentAmountOnCheckout != paymentAmoutFromPayPal) { Response.Redirect("CheckoutError.aspx?" + "Desc=Amount%20total%20mismatch."); } } catch (Exception) { Response.Redirect("CheckoutError.aspx?" + "Desc=Amount%20total%20mismatch."); } // Get DB context. ApplicationDbContext _db = new ApplicationDbContext(); // Add order to DB. _db.Orders.Add(myOrder); _db.SaveChanges(); // Get the shopping cart items and process them. using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { List <CartItem> myOrderList = usersShoppingCart.GetCartItems(); // Add OrderDetail information to the DB for each product purchased. for (int i = 0; i < myOrderList.Count; i++) { // Create a new OrderDetail object. var myOrderDetail = new OrderDetail(); myOrderDetail.OrderId = myOrder.OrderId; myOrderDetail.Username = User.Identity.Name; myOrderDetail.ProductId = myOrderList[i].ProductId; myOrderDetail.Quantity = myOrderList[i].Quantity; myOrderDetail.UnitPrice = myOrderList[i].Product.UnitPrice; // Add OrderDetail to DB. _db.OrderDetails.Add(myOrderDetail); _db.SaveChanges(); } // Set OrderId. Session["currentOrderId"] = myOrder.OrderId; // Display Order information. List <Order> orderList = new List <Order>(); orderList.Add(myOrder); ShipInfo.DataSource = orderList; ShipInfo.DataBind(); // Display OrderDetails. OrderItemList.DataSource = myOrderList; OrderItemList.DataBind(); } } else { Response.Redirect("CheckoutError.aspx?" + retMsg); } } }
public List <CartItem> GetShoppingCartItems() { ShoppingCartActions action = new ShoppingCartActions(); return(action.GetCartItems()); }