示例#1
0
 private static string ToJqgridModel(this ebay_product value)
 {
     return(string.Format("<tr><td colspan='5'><strong>{0}</strong> <a href='{1}' target='_blank'>view</a></td></tr>", value.isActive?"Active":"Ended", value.ToExternalLink()));
 }
示例#2
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
            });
        }