public ActionResult ProductSettings(long?id) { string categoryid = ""; trademe_product trademeProduct = null; if (id.HasValue) { var p = repository.GetProduct(id.Value, subdomainid.Value); if (p != null && p.trademeID.HasValue) { trademeProduct = p.trademe_product; categoryid = p.trademe_product.categoryid; // expires entry if (p.trademe_product.isActive && p.trademe_product.endTime < DateTime.UtcNow) { p.trademe_product.isActive = false; repository.Save("ProductSettings"); } } } var viewmodel = new TrademeProductViewModel(trademeProduct, MASTERdomain, db); viewmodel.PopulateCategories(categoryid); return(View(viewmodel)); }
private TrademeExporter(string hostname) : base(hostname) { trademeproduct = new trademe_product(); }
public TrademeProductViewModel(trademe_product _trademeproduct, MASTERsubdomain sd, tradelrDataContext db) { categories = new List <IEnumerable <SelectListItem> >(); sitecategories = db.trademe_categories; currency = sd.currency.ToCurrency(); if (_trademeproduct == null) { // new product trademeproduct = new trademe_product(); quantity = 1; durations = Enumerable.Empty <SelectListItem>(); shippingCosts = Enumerable.Empty <TrademeShippingCost>(); freeShipping = true; } else { // existing product trademeproduct = _trademeproduct; isPosted = true; isActive = trademeproduct.isActive; isBrandNew = trademeproduct.isnew; onlyAuthenticated = trademeproduct.authenticatedOnly; isBold = trademeproduct.isBold; isFeatured = trademeproduct.isFeatured; isHomepageFeatured = trademeproduct.isHomepageFeatured; hasGallery = trademeproduct.hasGallery; // shipping costs shippingCosts = trademeproduct.trademe_shippingcosts.ToModel(); freeShipping = !shippingCosts.Any(); quantity = trademeproduct.quantity; var leafcategory = sitecategories.Single(x => x.id == trademeproduct.categoryid); durations = leafcategory.trademe_listingdurations.Where(x => x.categoryid == trademeproduct.categoryid) .Select(x => new SelectListItem() { Text = x.duration == 1? (x.duration + " day"):(x.duration + " days"), Value = x.duration.ToString(), Selected = x.duration == trademeproduct.duration }); ListingID = trademeproduct.listingid; // intervals if (trademeproduct.startTime.HasValue) { StartDate = trademeproduct.startTime.Value.ToString(GeneralConstants.DATEFORMAT_INVOICE); } if (trademeproduct.endTime.HasValue) { EndDate = trademeproduct.endTime.Value.ToString(GeneralConstants.DATEFORMAT_INVOICE); } // prices StartPrice = trademeproduct.startPrice.ToString("n" + currency.decimalCount); if (trademeproduct.buynowPrice.HasValue) { BuynowPrice = trademeproduct.buynowPrice.Value.ToString("n" + currency.decimalCount); } ReservePrice = trademeproduct.reservePrice.ToString("n" + currency.decimalCount); ViewLocation = trademeproduct.ToExternalLink(); ListingFees = trademeproduct.listingfees.HasValue? trademeproduct.listingfees.Value.ToString(): ""; } }