示例#1
0
		/// <summary>
		/// Gets the numeric id associated with a site.
		/// </summary>
		/// <param name="SiteCodeType">The <see cref="SiteCodeType"/>.</param>
		/// <returns>The numeric id associated with the <see cref="SiteCodeType"/>.</returns>
		public static int GetSiteID(SiteCodeType SiteCodeType)
		{
			if (!Enum.IsDefined(typeof(SiteValueEnum), SiteCodeType.ToString()))
				return 0;
			else
				return (int) Enum.Parse(typeof(SiteValueEnum), Enum.GetName(typeof(SiteCodeType), SiteCodeType));

		}
示例#2
0
 public int GetSiteID(SiteCodeType SiteCodeType)
 {
     if (!Enum.IsDefined(typeof(SiteValueEnum), SiteCodeType.ToString()))
     {
         return(0);
     }
     // ReSharper disable once AssignNullToNotNullAttribute
     return((int)Enum.Parse(typeof(SiteValueEnum), Enum.GetName(typeof(SiteCodeType), SiteCodeType)));
 }
示例#3
0
 /// <summary>
 /// Gets the numeric id associated with a site.
 /// </summary>
 /// <param name="SiteCodeType">The <see cref="SiteCodeType"/>.</param>
 /// <returns>The numeric id associated with the <see cref="SiteCodeType"/>.</returns>
 public static int GetSiteID(SiteCodeType SiteCodeType)
 {
     if (!Enum.IsDefined(typeof(SiteValueEnum), SiteCodeType.ToString()))
     {
         return(0);
     }
     else
     {
         return((int)Enum.Parse(typeof(SiteValueEnum), Enum.GetName(typeof(SiteCodeType), SiteCodeType)));
     }
 }
示例#4
0
        public ActionResult CategorySelector(ListingTypeCodeType type, SiteCodeType site, int?parentid, int?level)
        {
            Debug.Assert(parentid.HasValue || level.HasValue);

            var cats = db.ebay_categories.Where(x => x.siteid == site.ToString());

            if (parentid.HasValue)
            {
                cats = cats.Where(x => x.parentid == parentid.Value && x.categoryid != parentid.Value);
            }

            if (level.HasValue)
            {
                cats = cats.Where(x => x.level == level.Value);
            }

            var viewmodel = new EbayCategoryCondition();

            if (!cats.Any() && parentid.HasValue)
            {
                // we have reached a leaf, get item conditions
                var condition_category = db.ebay_categories.SingleOrDefault(x => x.siteid == site.ToString() &&
                                                                            x.categoryid == parentid.Value);
                if (condition_category != null)
                {
                    viewmodel.conditions = condition_category.ebay_conditions
                                           .Select(x => new IdName()
                    {
                        name = x.name,
                        id   = x.value.ToString()
                    });

                    viewmodel.durations = condition_category.ebay_listingdurations
                                          .Where(x => x.listingtypeid == type.ToString())
                                          .Select(x => new IdName()
                    {
                        name = EbayProductViewModel.DurationNames.ContainsKey(x.duration)?EbayProductViewModel.DurationNames[x.duration]:x.duration,
                        id   = x.duration
                    });
                }
            }
            else
            {
                viewmodel.categories = cats.Select(x => new IdName()
                {
                    id   = x.categoryid.ToString(),
                    name = x.name
                });
            }

            return(Json(viewmodel.ToJsonOKData(), JsonRequestBehavior.AllowGet));
        }
示例#5
0
        public ActionResult PopulateNewEbaySiteDetails(SiteCodeType site)
        {
            var token = repository.GetOAuthToken(subdomainid.Value, OAuthTokenType.EBAY, true);

            var service = new CategoryService(token.token_key);

            // get categories
            if (db.ebay_categories.Count(x => x.siteid == site.ToString()) == 0)
            {
                var collections = service.GetCategories(site);

                foreach (CategoryType category in collections)
                {
                    var entry = new ebay_category();
                    entry.siteid     = site.ToString();
                    entry.categoryid = int.Parse(category.CategoryID);
                    entry.level      = category.CategoryLevel;
                    entry.name       = category.CategoryName;
                    entry.parentid   = int.Parse(category.CategoryParentID[0]);
                    entry.leaf       = category.LeafCategory;

                    db.ebay_categories.InsertOnSubmit(entry);
                }

                repository.Save();
            }

            var resp = service.GetEbayDetails(site);

            // populate dispatch time
            if (db.ebay_dispatchtimes.Count(x => x.siteid == site.ToString()) == 0)
            {
                foreach (DispatchTimeMaxDetailsType entry in resp.DispatchTimeMaxDetails)
                {
                    var time = new ebay_dispatchtime();
                    time.siteid       = site.ToString();
                    time.name         = entry.Description;
                    time.dispatchTime = entry.DispatchTimeMax;
                    db.ebay_dispatchtimes.InsertOnSubmit(time);
                }

                repository.Save();
            }

            // populate shipping locations
            if (db.ebay_shippinglocations.Count(x => x.siteid == site.ToString()) == 0)
            {
                foreach (ShippingLocationDetailsType entry in resp.ShippingLocationDetails)
                {
                    var loc = new ebay_shippinglocation();
                    loc.description = entry.Description;
                    loc.location    = entry.ShippingLocation;
                    loc.siteid      = site.ToString();
                    db.ebay_shippinglocations.InsertOnSubmit(loc);
                }
                repository.Save();
            }

            // populate shipping services
            if (db.ebay_shippingservices.Count(x => x.siteid == site.ToString()) == 0)
            {
                // shipping details
                foreach (ShippingServiceDetailsType entry in resp.ShippingServiceDetails)
                {
                    var ship = new ebay_shippingservice();
                    ship.siteid            = site.ToString();
                    ship.description       = entry.Description;
                    ship.servicetype       = entry.ShippingService;
                    ship.isInternational   = entry.InternationalService;
                    ship.requiresDimension = entry.DimensionsRequired;
                    ship.requiresWeight    = entry.WeightRequired;

                    db.ebay_shippingservices.InsertOnSubmit(ship);
                }
                repository.Save();
            }

            // now go through and populate category related services
            foreach (var category in db.ebay_categories.AsQueryable().Where(x => x.leaf))
            {
                if (category.done.HasValue && category.done.Value)
                {
                    continue;
                }
                var call = service.GetCategoryFeatures(category.categoryid, category.siteid.ToEnum <SiteCodeType>());

                var features = call.CategoryList;

                if (features.Count > 1)
                {
                    Syslog.Write(string.Format("{0} more than 1 features", category.categoryid));
                }

                // get listing duration
                foreach (ListingDurationReferenceType type in call.SiteDefaults.ListingDuration)
                {
                    foreach (ListingDurationDefinitionType def in call.FeatureDefinitions.ListingDurations.ListingDuration)
                    {
                        if (def.durationSetID == type.Value)
                        {
                            foreach (string entry in def.Duration)
                            {
                                var duration = new ebay_listingduration();
                                duration.listingtypeid = type.type.ToString();
                                duration.duration      = entry;
                                if (!category.ebay_listingdurations.Any(x => x.listingtypeid == duration.listingtypeid &&
                                                                        x.duration == duration.duration))
                                {
                                    category.ebay_listingdurations.Add(duration);
                                }
                            }
                        }
                    }
                }

                CategoryFeatureType feature = features[0];

                // if condition is available
                if (feature.ConditionEnabledSpecified && (feature.ConditionEnabled == ConditionEnabledCodeType.Enabled || feature.ConditionEnabled == ConditionEnabledCodeType.Required))
                {
                    //iterate through each condition node
                    foreach (ConditionType condition in feature.ConditionValues.Condition)
                    {
                        var con = new ebay_condition();
                        con.name  = condition.DisplayName;
                        con.value = condition.ID;
                        if (!category.ebay_conditions.Any(x => x.name == con.name && x.value == con.value && x.ebayrowid == category.id))
                        {
                            category.ebay_conditions.Add(con);
                            db.SubmitChanges();
                        }
                    }
                }

                if (feature.ReturnPolicyEnabled)
                {
                    category.requiresReturnPolicy = true;
                }
                else
                {
                    category.requiresReturnPolicy = false;
                }
                category.done = true;
                db.SubmitChanges();
            }

            return(Content("done"));
        }
示例#6
0
        public EbayProductViewModel(ebay_product _ebayproduct, MASTERsubdomain sd, tradelrDataContext db)
        {
            categories     = new List <IEnumerable <SelectListItem> >();
            sitecategories = db.ebay_categories.Where(x => x.siteid == siteid.ToString());
            currency       = sd.currency.ToCurrency();

            if (_ebayproduct == null)
            {
                // new product
                this.ebayproduct = new ebay_product();
                siteid           = SiteCodeType.US;
                includeAddress   = true;
                quantity         = 1;
                conditions       = Enumerable.Empty <SelectListItem>();
                durations        = Enumerable.Empty <SelectListItem>();
                TypeList         = typeof(ListingType).ToSelectList(true, null, null, ListingType.FixedPriceItem.ToString());
            }
            else
            {
                // existing product
                ebayproduct    = _ebayproduct;
                siteid         = ebayproduct.siteid.ToEnum <SiteCodeType>();
                includeAddress = ebayproduct.includeAddress;
                isPosted       = true;
                isActive       = ebayproduct.isActive;
                quantity       = ebayproduct.quantity;

                var leafcategory = sitecategories.Single(x => x.categoryid == ebayproduct.categoryid);

                durations = leafcategory.ebay_listingdurations.Where(x => x.listingtypeid == ebayproduct.listingType)
                            .Select(x => new SelectListItem()
                {
                    Text = DurationNames.ContainsKey(x.duration)
                                                 ? DurationNames[x.duration]
                                                 : x.duration,
                    Value    = x.duration,
                    Selected = x.duration == ebayproduct.duration
                });
                conditions = leafcategory.ebay_conditions.Select(x => new SelectListItem()
                {
                    Text     = x.name,
                    Value    = x.value.ToString(),
                    Selected =
                        x.value == ebayproduct.condition
                });

                ListingID = ebayproduct.ebayid;

                // intervals
                if (ebayproduct.startTime.HasValue)
                {
                    StartDate = ebayproduct.startTime.Value.ToString(GeneralConstants.DATEFORMAT_INVOICE);
                }

                if (ebayproduct.endTime.HasValue)
                {
                    EndDate = ebayproduct.endTime.Value.ToString(GeneralConstants.DATEFORMAT_INVOICE);
                }

                // prices
                if (ebayproduct.startPrice.HasValue)
                {
                    StartPrice = ebayproduct.startPrice.Value.ToString("n" + currency.decimalCount);
                }
                if (ebayproduct.buynowPrice.HasValue)
                {
                    BuynowPrice = ebayproduct.buynowPrice.Value.ToString("n" + currency.decimalCount);
                }
                if (ebayproduct.reservePrice.HasValue)
                {
                    ReservePrice = ebayproduct.reservePrice.Value.ToString("n" + currency.decimalCount);
                }

                ViewLocation = ebayproduct.ToExternalLink();
                ListingFees  = ebayproduct.listingFees;

                TypeList = typeof(ListingType)
                           .ToSelectList(true, null, null,
                                         Listing.GetTradelrSupportedType(ebayproduct.listingType.ToEnum <ListingTypeCodeType>()).ToString());
            }

            dispatchTimes = db.ebay_dispatchtimes
                            .Where(x => x.siteid == siteid.ToString())
                            .OrderBy(x => x.dispatchTime)
                            .Select(x => new SelectListItem()
            {
                Text     = x.name,
                Value    = x.dispatchTime.ToString(),
                Selected = x.dispatchTime == ebayproduct.dispatchTime
            });

            shippingProfiles = sd.ebay_shippingprofiles
                               .Where(x => x.siteid == siteid.ToString())
                               .Select(x => new SelectListItem()
            {
                Text     = x.title,
                Value    = x.id.ToString(),
                Selected = x.id == ebayproduct.profileid
            });
        }
示例#7
0
 public int GetSiteID(SiteCodeType SiteCodeType)
 {
     if (!Enum.IsDefined(typeof(SiteValueEnum), SiteCodeType.ToString()))
     {
         return 0;
     }
     // ReSharper disable once AssignNullToNotNullAttribute
     return (int)Enum.Parse(typeof(SiteValueEnum), Enum.GetName(typeof(SiteCodeType), SiteCodeType));
 }