//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()); } }
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 List <CartItem> UpdateCartItems() { using (CartController cartController = new CartController()) { String cartId = cartController.GetCurrentCartId(); CartController.ShoppingCartUpdates[] cartUpdates = new CartController.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 = Guid.Parse(Convert.ToString(rowValues["Product.Id"])); 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].Quantity = Convert.ToInt16(quantityTextBox.Text.ToString()); } cartController.UpdateShoppingCart(cartId, cartUpdates); CartList.DataBind(); lblTotal.Text = String.Format("{0:c}", cartController.GetTotalPrice()); return(cartController.GetAllCartItems()); } }
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 void GetAllCartItems() { if (Convert.ToInt32(Session["UserId"]) == 0) { EmptyCart.Visible = true; CartItems.Visible = false; } else { List <ShoppingCart_Result> objList = new List <ShoppingCart_Result>(); using (var entities = new ShoppingCartEntities()) objList = entities.ShoppingCart(Convert.ToInt32(Session["UserId"])).ToList <ShoppingCart_Result>(); if (objList.Count != 0) //cart table is not empty { EmptyCart.Visible = false; CartItems.Visible = true; CartList.DataSource = objList; //allocate data - objlist contain all the products CartList.DataBind(); //bind } else { EmptyCart.Visible = true; CartItems.Visible = false; } } }
public ActionResult GetCartResultList(bool isAjaxRequest) { CartList cartList = new CartList(); cartList.CartViewModelList = this.RefreshList(); string msg = string.Empty; //List<SelectListItem> QtyList = new List<SelectListItem>(); //for (int count = 1; count <= 10; count++) //{ // SelectListItem qty = new SelectListItem(); // qty.Text = Convert.ToString(count); // qty.Value = Convert.ToString(count); // QtyList.Add(qty); //} //ViewBag.qtylst = QtyList; if (cartList.CartViewModelList.Count() <= 0) { msg = CommonFunction.ErrorMessage("Cart.", " No product found."); } if (isAjaxRequest) { return(Json(new { msg = msg, html = this.RenderRazorViewToString("_getCartList", cartList) }, JsonRequestBehavior.AllowGet)); } else { return(PartialView("_getCartList", cartList)); } }
public string CreateOrder(CartList cart, InquiryMst inquiry) { _context.CartLists.Add(cart); _context.InquiryMsts.Add(inquiry); _context.SaveChanges(); return("Successfully Create Order!"); }
public List <CARTITEM> UpdateCartItems() { using (ShoppingCart shoppingCart = new ShoppingCart()) { int cartId = shoppingCart.getCartId(); ShoppingCart.ShoppingCartUpdates[] cartUpdates = new ShoppingCart.ShoppingCartUpdates[CartList.Rows.Count]; for (int i = 0; i < CartList.Rows.Count; i++) { //This is to store the new values from the entered value in the grid view 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()); } shoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates); CartList.DataBind(); lblTotal.Text = String.Format("{0:c}", shoppingCart.GetTotal()); return(shoppingCart.GetCartItems()); } }
public ActionResult DeleteCart(Guid cartId) { var objResponse = new ResponseObject(); CartList cartList = new CartList(); string SessionID = string.Empty; if (Session["sessionid"] == null) { SessionID = Convert.ToString(Session["sessionid"]); } string userName = string.IsNullOrEmpty(Convert.ToString(User.Identity.Name)) ? string.Empty : User.Identity.Name; var user = UserManager.Users.Where(u => u.Email == userName).FirstOrDefault(); CartBL obj = new CartBL(); int value = obj.DeleteCart(cartId, SessionID, user); obj = null; if (value > 0) { objResponse.IsSuccess = "true"; objResponse.StrResponse = CommonFunction.SuccessMessage("Cart.", "Product deleted successfully."); cartList.CartViewModelList = this.RefreshList(); } else { objResponse.IsSuccess = "false"; objResponse.StrResponse = CommonFunction.ErrorMessage("Cart.", "Something went wrong!"); } return(Json(new { html = this.RenderRazorViewToString("_getCartList", cartList), objResponse }, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> RefreshCart([FromBody] CartList data, string username) { try { var cartFilter = Builders <Cart> .Filter.Eq("UserName", username); var cartCollection = _db.GetCollection <Cart>("Cart"); var result = cartCollection.DeleteManyAsync(cartFilter).Result; if (data.ListOfProducts.Count > 0) { data.ListOfProducts.ToList().ForEach(c => c.UserName = username); var authCollection = _db.GetCollection <Cart>("Cart"); await authCollection.InsertManyAsync(data.ListOfProducts); } return(Ok(new ResponseData { Code = "200", Message = "Inserted", Data = null })); } catch (Exception ex) { LoggerDataAccess.CreateLog("AuthController", "RefreshCart", "RefreshCart", ex.Message); return(BadRequest(new ResponseData { Code = "400", Message = "Failed", Data = ex.Message })); } }
public async Task <IActionResult> Edit(string id, [Bind("Id,ProductName,Mrp")] CartList cartList) { if (id != cartList.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cartList); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CartListExists(cartList.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(cartList)); }
async Task ExecuteLoadCartCommand() { if (IsBusy) { return; } IsBusy = true; try { var items = await DataStore.GetCartAsync(true); foreach (var item in items) { CartList.Add(item); } total = 0; foreach (var prod in CartList) { total += float.Parse(prod.Price.Remove(prod.Price.Length - 2)); totalbind = total.ToString(); Debug.WriteLine(totalbind); } } catch (Exception ex) { Debug.WriteLine("chedy"); Debug.WriteLine(ex); } finally { IsBusy = false; } }
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()); } }
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() { var cartManager = new Logic.CartManager(); var cartId = ShoppingCartActions.GetCartId(); Domain.Models.ShoppingCartUpdates[] cartUpdates = new Domain.Models.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()); } cartManager.UpdateShoppingCartDatabase(cartId, cartUpdates); CartList.DataBind(); lblTotal.Text = $"{cartManager.GetCartTotal(cartId):c}"; return(cartManager.GetCartItems(cartId)); }
//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()); } }
public bool SetAsUsualOrder(Guid idLista) { CartList oList = GetListById(idLista); oList.PedidoHabitual = true; db.SaveChanges(); return(true); }
public ActionResult DeleteConfirmed(string id) { CartList cartList = db.CartLists.Find(id); db.CartLists.Remove(cartList); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task GetShoppingCartItems() { ShoppingCartActions actions = new ShoppingCartActions(); var cartItems = await actions.GetCartItems(); CartList.DataSource = cartItems; CartList.DataBind(); }
protected void UpdateBtn_Click(object sender, EventArgs e) { //https://docs.microsoft.com/en-us/aspnet/aspnet/overview/web-development-best-practices/what-not-to-do-in-aspnet-and-what-to-do-instead#reliability-and-performance Page.RegisterAsyncTask(new PageAsyncTask(async() => { var cartItems = await UpdateCartItems(); CartList.DataSource = cartItems; CartList.DataBind(); })); }
private void UpdateCart() { CartList.DataSource = CartActions.GetCart(); CartList.DataBind(); if (CartList.Rows.Count > 0) { Label lbltotal = CartList.FooterRow.Cells[4].FindControl("lblTotal") as Label; lbltotal.Text = CartActions.GetCart().Sum(a => a.LineTotal).ToString("c"); } }
protected void Page_Load(object sender, EventArgs e) { double bookcost; string searchString = (string)Session["SearchString"]; if (!IsPostBack) { if (Request.UrlReferrer.AbsolutePath == "/ConfirmationPage") { Response.Write("<script language=javascript>alert('ORDER CANCELED: emptying shopping cart.');</script>"); var datareset = Session["EmptySetForCart"]; CartList.DataBind(); } else { if (searchString == "Linda Prince") { var dataset = Session["dataSource"]; CartList.DataSource = dataset; CartList.DataBind(); totalBooksInCart.Text = totalBooksInCart.Text + " " + CartList.Rows.Count.ToString(); bookcost = 22; Session["bookcost"] = bookcost; subTotal.Text = subTotal.Text + " " + $"{bookcost}"; } else { var dataset = Session["dataSource"]; CartList.DataSource = dataset; CartList.DataBind(); totalBooksInCart.Text = totalBooksInCart.Text + " " + CartList.Rows.Count.ToString(); bookcost = 78.73; Session["bookcost"] = bookcost; subTotal.Text = subTotal.Text + " " + $"{bookcost}"; } } } else { if (Request.UrlReferrer.AbsolutePath == "/ConfirmationPage") { var datareset = Session["EmptySetForCart"]; CartList.DataBind(); } else { var dataset = Session["dataSource"]; CartList.DataSource = dataset; CartList.DataBind(); totalBooksInCart.Text = totalBooksInCart.Text + " " + CartList.Rows.Count.ToString(); subTotal.Text = subTotal.Text + " " + "500"; } } }
public async Task <IActionResult> Create([Bind("Id,ProductName,Mrp")] CartList cartList) { if (ModelState.IsValid) { _context.Add(cartList); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(cartList)); }
public bool OnItemLongClick(AdapterView parent, View view, int position, long id) {//מחיקת המוצר ברגע שלוחצים לחיצה ארוכה var db = new SQLiteConnection(Helper.Path()); //הורדת המחיר של המוצר מהמחיר הכולל h = h - CartList[position].GetPrice(); payment.Text = h.ToString(); db.Delete(CartList[position]); //מחיקת המוצר מהטבלה CartList.RemoveAt(position); //מחיקת המוצר מהרשימה listadapter.NotifyDataSetChanged(); return(true); }
public Order() { App.Current.Properties["MenuType"] = null; InitializeComponent(); //ObjectDataProvider menuProvider = this.Resources["Menu"] as ObjectDataProvider; //menuProvider = Resources["ShoppingCart"] as ObjectDataProvider; //CartList cartlist = menuProvider.Data as CartList; //ShoppingCart = cartlist; ShoppingCart = App.Current.Resources["CartListDataSource"] as CartList; //((INotifyPropertyChanged)ShoppingCart).PropertyChanged += new PropertyChangedEventHandler(ShoppingCartChanged); }
//public ViewResult Index(string returnUrl) //{ // return View(new CartIndexViewModel // { // Cart = GetCart(), // ReturnUrl = returnUrl // }); //} public RedirectToActionResult RemoveFromCart(int Id, string returnUrl) { Species species = repository.Species.FirstOrDefault(p => p.Id == Id); if (species != null) { CartList cartlist = GetCart(); cartlist.RemoveItem(species); SaveCart(cartlist); } return(RedirectToAction("Index", new { returnUrl })); }
public ActionResult Edit([Bind(Include = "cartId,transactionId,itemCode,qty,price")] CartList cartList) { if (ModelState.IsValid) { db.Entry(cartList).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.itemCode = new SelectList(db.ItemMsts, "itemCode", "itemCode", cartList.itemCode); ViewBag.transactionId = new SelectList(db.TransactionMsts, "transactionId", "transactionId", cartList.transactionId); return(View(cartList)); }
protected void OnItemCommand(object sender, ListViewCommandEventArgs e) { if (String.Equals(e.CommandName, "Remove")) { computerList = GetComputers(); computerList.RemoveAt(0); CartList.DataSource = computerList; CartList.DataBind(); Cart cart = new Cart(computerList); Response.Cookies["computer"].Value = Cart.Serialize(cart); Quantity_Change(null, null); } }
public CartList CreateList(string name) { CartList oList = new CartList() { Nombre = name, F_Creacion = DateTime.Now, PedidoHabitual = false }; this.db.Lists.Add(oList); this.db.SaveChanges(); return(oList); }
// GET: Admin/CartLists/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CartList cartList = db.CartLists.Find(id); if (cartList == null) { return(HttpNotFound()); } return(View(cartList)); }