protected void MyProductsGridView_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var Img = new Image(); if (e.Row.Cells[1].Text != " ") { Img.ImageUrl = e.Row.Cells[1].Text; Img.Width = Unit.Pixel(20); Img.Height = Unit.Pixel(20); e.Row.Cells[1].Text = ""; e.Row.Cells[1].Controls.Add(Img); } MarketplaceProduct product = new MarketplaceProduct(Convert.ToInt32(e.Row.Cells[0].Text)); var link = string.Format("{0}user/advert/marketplace.aspx?pid={1}", AppSettings.Site.Url, product.Id); e.Row.Cells[2].Text = string.Format("<a href={0}>{1}</a>", link, e.Row.Cells[2].Text); } else if (e.Row.RowType == DataControlRowType.Header) { e.Row.Cells[1].Text = L1.IMAGE; e.Row.Cells[2].Text = L1.TITLE; e.Row.Cells[3].Text = L1.PRICE; e.Row.Cells[4].Text = U5006.SOLD + "/" + U5006.ADVERTISED; } }
public void BuildMarketplaceGrid() { List <MarketplaceProduct> MarketplaceProductsList = MarketplaceProduct.GetGeolocatedProducts(user); if (MarketplaceProductsList.Count < 1) { MarketEmptyPlaceHolder.Visible = true; MarketplaceProductsPlaceholder.Visible = false; } else { try { foreach (MarketplaceProduct Product in MarketplaceProductsList) { MarketplaceProductsPlaceholder.Controls.Add(GetMarketplaceProduct(Product)); } } catch (Exception ex) { ErrorLogger.Log(ex); throw ex; } } }
private void updateEisProduct(MarketplaceProduct product) { try { var eisProduct = _productService.GetProductByEisSKU(product.EisSKU); if (eisProduct == null) { return; } product.EisSKU = eisProduct.EisSKU; //eisProduct.Name = product.ProductTitle; // set the EIS product Package's Dimension eisProduct.Brand = product.Brand; eisProduct.Color = product.Color; eisProduct.EAN = product.EAN; eisProduct.Model_ = product.Model; // determine the product type id of the marketplace product eisProduct.ProductTypeId = _productTypeService.ConfigureProductTypeName(((ProductAmazon)product).ProductTypeName, ((ProductAmazon)product).ProductGroup); // set the product' package dimension if (product.PackageDimension != null) { eisProduct.PkgLength = product.PackageDimension.Length.Value; eisProduct.PkgWidth = product.PackageDimension.Width.Value; eisProduct.PkgHeight = product.PackageDimension.Height.Value; eisProduct.PkgLenghtUnit = product.PackageDimension.Length.Unit; // parse the weigh and its unit eisProduct.PkgWeight = product.PackageDimension.Weight.Value; eisProduct.PkgWeightUnit = product.PackageDimension.Weight.Unit; } // set the EIS product Item's dimension if (product.ItemDimension != null) { eisProduct.ItemLength = product.ItemDimension.Length.Value; eisProduct.ItemWidth = product.ItemDimension.Width.Value; eisProduct.ItemHeight = product.ItemDimension.Height.Value; eisProduct.ItemLenghtUnit = product.ItemDimension.Length.Unit; // parse the weigh and its unit eisProduct.ItemWeight = product.ItemDimension.Weight.Value; eisProduct.ItemWeightUnit = product.ItemDimension.Weight.Unit; } // save the chnages _productService.UpdateProduct(eisProduct.EisSKU, eisProduct); } catch (Exception ex) { _logger.LogError(LogEntryType.MarketplaceProductManager, EisHelper.GetExceptionMessage(ex), ex.StackTrace); } }
protected UserControl GetMarketplaceProduct(MarketplaceProduct Product) { UserControl objControl = (UserControl)Page.LoadControl("~/Controls/Advertisements/MarketplaceProduct.ascx"); var parsedControl = objControl as MarketplaceProductObjectControl; parsedControl.Object = Product; parsedControl.DataBind(); return(objControl); }
public BuyMarketplaceProductButtonGenerator(string username, int productId, int quantity, string deliveryAddress, string email, int?promotorId) { product = new MarketplaceProduct(productId); Amount = product.Price * quantity; Username = username; this.productId = product.Id; this.quantity = quantity; this.deliveryAddress = deliveryAddress; this.email = email; this.promotorId = promotorId; }
protected void BuyProductFromAdOrMarketplaceBalance_Click(object sender, EventArgs e) { ErrorMessage.Text = string.Empty; ErrorMessagePanel.Visible = false; var targetBalance = BalanceType.PurchaseBalance; if (((Button)sender).ID == "BuyProductFromMarketplaceBalance") { targetBalance = BalanceType.MarketplaceBalance; } try { int productId = Convert.ToInt32(((Button)sender).CommandArgument); int quantity = Convert.ToInt32(ProductInfoBuyCount.Text); string deliveryAddress = InputChecker.HtmlEncode(DeliveryAddressTextBox.Text, DeliveryAddressTextBox.MaxLength, U6005.DELIVERYADDRESS); string email = EmailTextBox.Text.Trim(); int?promotorId; if (Request.Params.Get("ref") != null) { promotorId = int.Parse(Request.Params.Get("ref")); } else { promotorId = null; } MarketplaceProduct product = new MarketplaceProduct(productId); product.Buy(Member.Current, quantity, deliveryAddress, email, targetBalance); MarketplaceAdd_BannerImage.ImageUrl = null; Response.Redirect("~/user/advert/marketplace.aspx?s=t"); } catch (MsgException ex) { ErrorMessage.Text = ex.Message; ErrorMessagePanel.Visible = true; } catch (Exception ex) { ErrorLogger.Log(ex); } }
protected void BuyMarketplaceProduct(string username, Money amount, string from, string transId, int productId, int quantity, string deliveryAddress, string email, int?promotorId, string cryptoCurrencyInfo) { MarketplaceProduct product = new MarketplaceProduct(productId); bool successful = false; try { product.BuyViaProcessor(username, quantity, email, deliveryAddress, amount, promotorId); successful = true; } catch { successful = false; } PaymentProcessor PP = PaymentAccountDetails.GetFromStringType(from); CompletedPaymentLog.Create(PP, "Marketplace Purchase", transId, false, username, amount, Money.Zero, successful, cryptoCurrencyInfo); }
protected void BuyProduct_Click(object sender, EventArgs e) { ErrorMessage.Text = string.Empty; ErrorMessagePanel.Visible = false; try { int productId = Convert.ToInt32(((Button)sender).CommandArgument); int quantity = Convert.ToInt32(ProductInfoBuyCount.Text); string deliveryAddress = InputChecker.HtmlEncode(DeliveryAddressTextBox.Text, DeliveryAddressTextBox.MaxLength, U6005.DELIVERYADDRESS); string email = EmailTextBox.Text.Trim(); int? promotorId = (int?)Session["MarketplacePromotorId"]; MarketplaceProduct product = new MarketplaceProduct(productId); if (Member.IsLogged) { Member buyer = user; if (!product.IsGeolocationMeet(buyer)) { throw new MsgException("You don't meet Geolocation constraints for this product."); } if (buyer.Id == product.SellerId) { throw new MsgException(U5006.BUYFROMYOURSELF); } } if (quantity > product.Quantity) { throw new MsgException(U5006.SELLERDOESNTHAVEENOUGHT); } if (AppSettings.Marketplace.MarketplaceAllowPurchaseFromPaymentProcessors) { string username = Member.IsLogged ? user.Name : MarketplaceMember.AnonymousUsername; PaymentProcessorButtonsPlaceHolder.Visible = true; var bg = new BuyMarketplaceProductButtonGenerator(username, productId, quantity, deliveryAddress, email, promotorId); PaymentButtons.Text = GenerateHTMLButtons.GetPaymentButtons(bg); } if (Member.IsLogged && AppSettings.Marketplace.MarketplaceAllowPurchaseFromAdBalance) { BuyProductFromAdBalance.Visible = true; } if (Member.IsLogged && AppSettings.Marketplace.AllowPurchaseFromMarketplaceBalance) { BuyProductFromMarketplaceBalance.Visible = true; } BuyProductButton.Visible = false; } catch (MsgException ex) { ErrorMessage.Text = ex.Message; ErrorMessagePanel.Visible = true; } catch (Exception ex) { ErrorLogger.Log(ex); } }
protected void Page_Load(object sender, EventArgs e) { AccessManager.RedirectIfDisabled(AppSettings.TitanFeatures.AdvertMarketplaceEnabled); if (Request.Params.Get("pid") != null && !SenderIsMenuButton) //open detail info about product { int ProductId = Convert.ToInt32(Request.Params.Get("pid")); MarketplaceProduct SelectedProduct = new MarketplaceProduct(ProductId); //insert data to info window MenuMultiView.ActiveViewIndex = 4; if (AppSettings.Marketplace.MarketplaceUsersPromoteByLinkEnabled) { if (Request.Params.Get("ref") == null && Session["MarketplacePromotorId"] == null && Member.IsLogged) { if (user.Membership.Id > Membership.Standard.Id) { AffiliateLinkPlaceHolder.Visible = true; ItemAffiliateLink = Request.Url.AbsoluteUri + "&ref=" + user.Id; } } else if (Request.Params.Get("ref") != null) { Session["MarketplacePromotorId"] = int.Parse(Request.Params.Get("ref")); } } ProductInfoImage.ImageUrl = SelectedProduct.ImagePath; ProductInfoTitle.Text = SelectedProduct.Title; ProductInfoDescription.Text = Mailer.ReplaceNewLines(SelectedProduct.Description); ProductInfoQuantity.Text = SelectedProduct.Quantity.ToString(); ProductInfoContact.Text = Mailer.ReplaceNewLines(SelectedProduct.Contact); BuyProductButton.Text = SelectedProduct.Price.ToString(); BuyProductButton.CommandArgument = ProductId.ToString(); BuyProductFromAdBalance.CommandArgument = ProductId.ToString(); BuyProductFromMarketplaceBalance.CommandArgument = ProductId.ToString(); } else if (Request.Params.Get("s") == "t") //success bought { SuccMessage.Text = U5006.YOUSUCCBOUGHTONMARKETPLACE; SuccMessagePanel.Visible = true; } else if (!string.IsNullOrWhiteSpace(Request.Params.Get("h"))) //confirm purchase { MenuMultiView.ActiveViewIndex = 5; foreach (Button b in MenuButtonPlaceHolder.Controls) { b.CssClass = ""; } SubMenuButton_MarketplaceConfirmBuying.CssClass = "ViewSelected"; ConfirmProductButton.Text = L1.CONFIRM; string hash = Request.Params.Get("h"); MarketplaceIPN ipn = TableHelper.SelectRows <MarketplaceIPN>(TableHelper.MakeDictionary("Hash", hash)).FirstOrDefault(); MarketplaceProduct product = new MarketplaceProduct(ipn.ProductId); ConfirmProductImage.ImageUrl = product.ImagePath; ConfirmProductTitle.Text = product.Title; ConfirmProductDescription.Text = Mailer.ReplaceNewLines(product.Description); ConfirmProductContact.Text = Mailer.ReplaceNewLines(product.Contact); if (ipn.Status == MarketplaceIPNStatus.Pending) { ConfirmProductButton.CommandArgument = ipn.Id.ToString(); } else if (ipn.Status == MarketplaceIPNStatus.Confirmed) { ConfirmProductButton.Visible = false; AlreadyConfirmedLiteral.Visible = true; AlreadyConfirmedLiteral.Text = string.Format("<div class='whitebox' style='width:220px'>{0}<div>", U5006.PRODUCTCONFIRMED); } if (ipn == null) { Response.Redirect("~/user/default.aspx"); } } if (!Member.IsLogged) { Master.HideSidebars(); } //Lang & Hint //GridView1.EmptyDataText = L1.NODATA; LangAdder.Add(SubMenuButton_MarketplaceProducts, U5006.MARKETPLACE); LangAdder.Add(SubMenuButton_MarketplaceAddProduct, U6005.ADDNEWPRODUCT); LangAdder.Add(SubMenuButton_MarketplaceConfirmBuying, U5006.PURCHASEDPRODUCTS); LangAdder.Add(MarketplaceAddButton, L1.ADDNEW); LangAdder.Add(MarketplaceAdd_BannerUploadValidCustomValidator, L1.ER_BANNERISNOTVALID, true); LangAdder.Add(MarketplaceAdd_BannerUploadSelectedCustomValidator, U5006.MUSTUPLOADIMAGE, true); LangAdder.Add(SubSubMenuButton_MarketplaceMyProducts, U5006.MYPRODUCTS); LangAdder.Add(RequiredFieldValidator1, L1.REQ_TITLE, true); LangAdder.Add(RequiredFieldValidator2, L1.REQ_DESC, true); LangAdder.Add(RequiredFieldValidator5, L1.CONTACT + " " + U3900.FIELDISREQUIRED, true); LangAdder.Add(DeliveryAddressRequired, U6005.DELIVERYADDRESSREQUIRED, true); LangAdder.Add(EmailRequired, L1.REG_REQ_EMAIL, true); LangAdder.Add(EmailRegex, L1.ER_BADEMAILFORMAT, true); BuyProductFromAdBalance.Text = string.Format(U6005.PAYWITH, U6012.PURCHASEBALANCE); BuyProductFromMarketplaceBalance.Text = string.Format(U6005.PAYWITH, U6008.MARKETPLACEBALANCE); SubSubMenuButton_MarketplaceMyProducts.Visible = SubMenuButton_MarketplaceAddProduct.Visible = AppSettings.Marketplace.CanUsersAddMarketplaceProducts && Member.IsLogged; PurchasedProductsGridView.Visible = Member.IsLogged; SubMenuButton_MarketplaceConfirmBuying.Visible = Member.IsLogged || !string.IsNullOrEmpty(Request.Params.Get("h")); BuildMarketplaceGrid(); if (!Page.IsPostBack) { MakeCategoriesList(); BindDataCountriesToDDL(); GeolocationCheckBox.Attributes.Add("onclick", "ManageGeoEvent();"); } ScriptManager.GetCurrent(this).RegisterPostBackControl(MarketplaceAdd_BannerUploadSubmit); }