private void MMainView_Click(object sender, EventArgs e) { int position = mRecyclerView.GetChildAdapterPosition((View)sender); bool alreadyExists = GlobalVariables.globalProductsOnCart.Any(x => x.productId == mProducts[position].Id); if (alreadyExists) { foreach (var item in GlobalVariables.globalProductsOnCart) { if (item.productId == mProducts[position].Id) { item.productPrice = item.productOrigPrice; //update price on click to reset the price on cart item.productDiscountAmount = 0.00M; //reset discount amt to 0 if already on cart item.productDiscountPercentage = 0.00M; //reset discount percentage to 0 if already on cart item.productCountOnCart = item.productCountOnCart + 1; item.productSubTotalPrice = (item.productCountOnCart) * item.productPrice; } } } else { GlobalVariables.globalProductsOnCart.Add(new ProductsOnCart() { productId = mProducts[position].Id, productName = mProducts[position].ProductName, productOrigPrice = GetProductPrice(position), productPrice = GetProductPrice(position), productCountOnCart = 1, productCategoryId = mProducts[position].ProductCategoryId, productCategory = mProducts[position].ProductCategory, productSizeId = mProducts[position].ProductSizeId, productSize = mProducts[position].ProductSize, sizeRank = mSizesDataAccess.SelectRecord(mProducts[position].ProductSizeId)[0].SizeRank, productSubTotalPrice = GetProductPrice(position), productDiscountAmount = 0.00M, productDiscountPercentage = 0.00M, parentProductId = mProducts[position].ParentProductId, parentProductName = mParentProductsDataAccess.SelectRecord(mProducts[position].ParentProductId)[0].ParentProductName }); } //update checkoutbutton. mCheckoutFragment.SetCheckoutButtonTotal(mBtnCheckoutButton, mCheckoutContext); var clickedProductRow = GlobalVariables.globalProductsOnCart.Where(o => o.productId == mProducts[position].Id).ToList(); if (mIsGrid) { ShowCurrentQuantityOnCartGrid(sender, clickedProductRow[0].productCountOnCart); } else { ShowCurrentQuantityOnCartList(sender, clickedProductRow[0].productCountOnCart); } }
private void FnGetData() { isSize = Intent.GetBooleanExtra("isSize", false); isEdit = Intent.GetBooleanExtra("isEdit", false); selectedRecordId = Intent.GetIntExtra("selectedRecordId", 0); mSizesDataAccess = new SizesDataAccess(); mCategoriesDataAccess = new CategoriesDataAccess(); if (isEdit) { if (isSize) { selectedSize = mSizesDataAccess.SelectRecord(selectedRecordId)[0]; } else { selectedCategory = mCategoriesDataAccess.SelectRecord(selectedRecordId)[0]; } } }
private int GetSizeRank(int id) { return(mSizesDataAccess.SelectRecord(id)[0].SizeRank); }