private string ListProductToEBay( Product product, EBayTemplate template, EBayCategory category, Boolean isScheduleDate, DateTime scheduleDateTime) { string eBayItemID = string.Empty; EBayAccess access = new EBayAccess(UrlPath.StorefrontUrl); eBayItemID = access.AddItem(product, template, category, isScheduleDate, scheduleDateTime); if (access.HasError) { string errorMessage = string.Empty; foreach (EBayErrorType error in access.ErrorTypeList) { errorMessage += HttpUtility.HtmlEncode(error.ErrorLongMessage) + " (" + error.ErrorCode + ")<br/>"; } uxMessage.DisplayError(errorMessage); } return(eBayItemID); }
private void SaveListing(string eBayItemID, EBayTemplate template) { EBayAccess acc = new EBayAccess(); EBayItem item = GetEBayItemDetailByID(eBayItemID, template); ApiContext apiContext = acc.GetApiContext(template.EBayListSite); EBayList eBayList = new EBayList(); if (item.Type.Equals("Chinese")) { eBayList.BuyItNowPrice = ConvertUtilities.ToDecimal(item.Bidding_BuyItNowPrice); } else { eBayList.BuyItNowPrice = ConvertUtilities.ToDecimal(item.BuyItNowPrice); } eBayList.BidPrice = (decimal)item.Bidding_CurrentPrice; eBayList.ItemName = item.Title; eBayList.ItemNumber = item.ID; eBayList.LastStatus = (EBayList.EBayListStatus)Enum.Parse(typeof(EBayList.EBayListStatus), item.ListingStatus, true); eBayList.ListDate = item.StartTime; eBayList.ListType = (EBayList.EBayListType)Enum.Parse(typeof(EBayList.EBayListType), item.Type, true); eBayList.QtyLeft = item.QuantityLeft; eBayList.LastUpdate = DateTime.Now; eBayList.ViewUrl = item.ViewUrl; eBayList.Currency = item.Currency; eBayList = DataAccessContextDeluxe.EBayListRepository.Save(eBayList); }
private void ShowListingFee(string[] productIDList, EBayTemplate template, EBayCategory category, Boolean isScheduleDate, DateTime scheduleDateTime) { EBayAccess access = new EBayAccess(UrlPath.StorefrontUrl); IList <EBayFee> feeList = new List <EBayFee>(); int productCount = productIDList.Length - 1; string totalFee = string.Empty; string firstProductID = productIDList[0]; DataTable dt = new DataTable(); dt.Columns.Add("feeName"); dt.Columns.Add("feeCost"); if (!String.IsNullOrEmpty(firstProductID)) { feeList = access.VerifyAddItem(GetProductByProductID(firstProductID), template, category, isScheduleDate, scheduleDateTime); foreach (EBayFee fee in feeList) { if (fee.Name.Equals("ListingFee")) //Total fee for listing the item { Currency currency = DataAccessContext.CurrencyRepository.GetOne(fee.Currency.ToString()); totalFee = currency.FormatPrice((fee.Value * productCount).ToString()); DataRow rowCostPerItem = dt.NewRow(); rowCostPerItem["feeName"] = "Per-Item cost"; rowCostPerItem["feeCost"] = currency.FormatPrice(fee.Value.ToString()); dt.Rows.Add(rowCostPerItem); break; } } foreach (EBayFee fee in feeList) { if (fee.Value != 0 && !fee.Name.Equals("ListingFee")) { Currency currency = DataAccessContext.CurrencyRepository.GetOne(fee.Currency.ToString()); DataRow dr = dt.NewRow(); dr["feeName"] = "- " + fee.Name; dr["feeCost"] = currency.FormatPrice(fee.Value.ToString()); dt.Rows.Add(dr); } } DataRow rowTotal = dt.NewRow(); rowTotal["feeName"] = "Total fees for " + productCount.ToString() + " item(s)"; rowTotal["feeCost"] = totalFee; dt.Rows.Add(rowTotal); } uxFeeDetailGrid.DataSource = dt; uxFeeDetailGrid.DataBind(); uxFeeDetailGrid.Rows[0].CssClass = "CssAdminContentTop"; uxFeeDetailGrid.Rows[uxFeeDetailGrid.Rows.Count - 1].CssClass = "CssAdminContentTop"; }
private EBayCategory GetEBayCategoryByTemplate(EBayTemplate template) { EBayAccess access = new EBayAccess(); EBayCategory primaryCategory = access.GetCategoriesDetailsByID(template.PrimaryeBayCategoryID, template.EBayListSite); EBayCategory eBayCategory = primaryCategory; if (!template.SecondaryeBayCategoryID.Equals("0")) { EBayCategory secondaryCategory = access.GetCategoriesDetailsByID(template.SecondaryeBayCategoryID, template.EBayListSite); eBayCategory.SecondaryCategoryID = secondaryCategory.PimaryCategoryID; eBayCategory.SecondaryCategoryName = secondaryCategory.PimaryCategoryName; } return(eBayCategory); }
private void CreateList() { EBayTemplate template = GetEBayTemplateByID(uxHiddenSelectedTemplateID.Value); foreach (string productID in ProductIDList) { if (!string.IsNullOrEmpty(productID)) { string eBayItemID = ListProductToEBay( GetProductByProductID(productID), template, GetEBayCategoryByTemplate(template), ConvertUtilities.ToBoolean(uxHiddenIsSchedule.Value), ConvertUtilities.ToDateTime(uxHiddenScheduleDateTime.Value)); if (String.IsNullOrEmpty(eBayItemID)) { return; } SaveListing(eBayItemID, template); } } MainContext.RedirectMainControl("EBayListing.ascx"); }
private EBayItem GetEBayItemDetailByID(string eBayItemID, EBayTemplate template) { EBayAccess access = new EBayAccess(); return(access.GetItemDetail(eBayItemID, access.GetApiContext(template.EBayListSite))); }
private Boolean CheckCondition(string templateID, string[] productIDList) { Boolean conditionPass = true; EBayAccess access = new EBayAccess(UrlPath.StorefrontUrl); EBayTemplate eBayTemplate = DataAccessContextDeluxe.EBayTemplateRepository.GetOne(templateID); EBayCategory category = access.GetCategoriesDetailsByID(eBayTemplate.PrimaryeBayCategoryID, eBayTemplate.EBayListSite); EBayCategoryFeature feature = access.GetCategoryFeatureDetail(category.PimaryCategoryID, category.CategoryLevel, eBayTemplate.EBayListSite); ShowMessageByCondition(feature, category); if (feature.IsReturnPolicyEnabled) { if (!eBayTemplate.IsAcceptReturn) { lcMessage.Text = "Return Policy is required for listing. Please check your listing template."; return(false); } } foreach (string productID in productIDList) { if (productID.Equals("")) { break; } Product product = GetProductByProductID(productID); double productPrice = 0.0; foreach (ProductPrice price in product.ProductPrices) { if (price.StoreID.Equals("0")) //use defalut price { productPrice = (double)price.Price; break; } } if (eBayTemplate.DomesticShippingType == "Calculate" || eBayTemplate.InternationalShippingType == "Calculate") { if (product.Weight <= 0) { lcMessage.Text = "Cannot list to eBay because some product does not have weight."; return(false); } } if (String.IsNullOrEmpty(product.ShortDescription)) { lcMessage.Text = "Cannot list to eBay because some product does not have short description."; return(false); } if (product.IsCustomPrice) { lcMessage.Text = "Cannot list to eBay because some product(s) enabled custom price."; return(false); } if (product.IsCallForPrice) { lcMessage.Text = "Cannot list to eBay because some product(s) enabled call for price."; return(false); } IList <ProductOptionGroup> optionGroupList = product.ProductOptionGroups; if (optionGroupList.Count > 0) { lcMessage.Text = "Cannot list to eBay because some product(s) has option."; return(false); } if (product.IsRecurring) { lcMessage.Text = "Cannot list to eBay because some product(s) enabled recurring option."; return(false); } double eBayTemplateReservePrice = 0.0; double eBayTemplateStartingPrice = 0.0; double eBayTemplateBuyItNowPrice = 0.0; if (eBayTemplate.SellingMethod.Equals("Online Auction")) { if (eBayTemplate.UseReservePrice) { switch (eBayTemplate.ReservePriceType) { case "ProductPrice": eBayTemplateReservePrice = productPrice; break; case "PricePlusAmount": eBayTemplateReservePrice = productPrice + ConvertUtilities.ToDouble(eBayTemplate.ReservePriceValue); break; case "PricePlusPercentage": eBayTemplateReservePrice = productPrice + (productPrice * (ConvertUtilities.ToDouble(eBayTemplate.ReservePriceValue) / 100)); break; case "CustomPrice": eBayTemplateReservePrice = ConvertUtilities.ToDouble(eBayTemplate.ReservePriceValue); break; default: eBayTemplateReservePrice = productPrice; break; } } if (eBayTemplate.UseBuyItNowPrice) { switch (eBayTemplate.BuyItNowPriceType) { case "ProductPrice": eBayTemplateBuyItNowPrice = productPrice; break; case "PricePlusAmount": eBayTemplateBuyItNowPrice = productPrice + ConvertUtilities.ToDouble(eBayTemplate.BuyItNowPriceValue); break; case "PricePlusPercentage": eBayTemplateBuyItNowPrice = productPrice + (productPrice * (ConvertUtilities.ToDouble(eBayTemplate.BuyItNowPriceValue) / 100)); break; case "CustomPrice": eBayTemplateBuyItNowPrice = ConvertUtilities.ToDouble(eBayTemplate.BuyItNowPriceValue); break; default: eBayTemplateBuyItNowPrice = productPrice; break; } } switch (eBayTemplate.StartingPriceType) { case "ProductPrice": eBayTemplateStartingPrice = productPrice; break; case "PricePlusAmount": eBayTemplateStartingPrice = productPrice + ConvertUtilities.ToDouble(eBayTemplate.StartingPriceValue); break; case "PricePlusPercentage": eBayTemplateStartingPrice = productPrice + (productPrice * (ConvertUtilities.ToDouble(eBayTemplate.StartingPriceValue) / 100)); break; case "CustomPrice": eBayTemplateStartingPrice = ConvertUtilities.ToDouble(eBayTemplate.StartingPriceValue); break; default: eBayTemplateStartingPrice = productPrice; break; } if (eBayTemplate.UseReservePrice) { if (eBayTemplateReservePrice < feature.MinimumReservePrice) { lcMessage.Text = "Reserve Price in template is less than eBay minimun reserve price. Please check your template."; return(false); } if (eBayTemplateReservePrice <= eBayTemplateStartingPrice) { lcMessage.Text = "The starting price must be less than the reserve price. Please check your template."; return(false); } } if (eBayTemplate.UseBuyItNowPrice) { double eBayTemplateStartingPricePlusTenPercent = eBayTemplateStartingPrice + (eBayTemplateStartingPrice * 0.1); if (eBayTemplateBuyItNowPrice <= eBayTemplateStartingPricePlusTenPercent) { lcMessage.Text = "Buy It Now price should be at least 10% more than your starting price. Please check your template."; return(false); } } } } access.VerifyAddItem(GetProductByProductID(productIDList[0]), eBayTemplate, category, false, DateTime.Now); if (access.HasError) { foreach (EBayErrorType error in access.ErrorTypeList) { lcMessage.Text += HttpUtility.HtmlEncode(error.ErrorLongMessage) + " (" + error.ErrorCode + ")<br/>"; } lcMessage.ForeColor = System.Drawing.Color.Red; return(false); } return(conditionPass); }
public void PopulateControls(string templateID, string[] productIDList, Boolean isScheduleDate, DateTime scheduleDateTime) { EBayTemplate template = GetEBayTemplateByID(templateID); ShowListingFee(productIDList, template, GetEBayCategoryByTemplate(template), isScheduleDate, scheduleDateTime); }