public void RenderModel(StringBuilder sb, SingleProductViewModel model, MerchantTribeApplication app) { if (model.IsLastItem == true) { sb.Append("<div class=\"record lastrecord\">"); } else if (model.IsFirstItem == true) { sb.Append("<div class=\"record firstrecord\">"); } else { sb.Append("<div class=\"record\">"); } sb.Append("<div class=\"recordimage\">"); sb.Append("<a href=\"" + model.ProductLink + "\">"); sb.Append("<img src=\"" + model.ImageUrl + "\" alt=\"" + HttpUtility.HtmlEncode(model.Item.ImageFileSmallAlternateText) + "\" /></a>"); sb.Append("</div>"); sb.Append("<div class=\"recordname\">"); sb.Append("<a href=\"" + model.ProductLink + "\">" + HttpUtility.HtmlEncode(model.Item.ProductName) + "</a>"); sb.Append("</div>"); sb.Append("<div class=\"recordsku\">"); sb.Append("<a href=\"" + model.ProductLink + "\">" + HttpUtility.HtmlEncode(model.Item.Sku) + "</a>"); sb.Append("</div>"); sb.Append("<div class=\"recordprice\">"); sb.Append("<a href=\"" + model.ProductLink + "\">" + model.UserPrice.DisplayPrice(true) + "</a>"); sb.Append("</div>"); sb.Append("</div>"); }
private List<SingleProductViewModel> PrepProducts(List<Product> products, MerchantTribeApplication app) { List<SingleProductViewModel> result = new List<SingleProductViewModel>(); int columnCount = 1; foreach (Product p in products) { SingleProductViewModel model = new SingleProductViewModel(p, app); bool isLastInRow = false; bool isFirstInRow = false; if ((columnCount == 1)) { isFirstInRow = true; } if ((columnCount == 3)) { isLastInRow = true; columnCount = 1; } else { columnCount += 1; } //model.IsFirstItem = isFirstInRow; //model.IsLastItem = isLastInRow; result.Add(model); } return result; }
public void Render(StringBuilder sb, MerchantTribe.Commerce.Catalog.Product p, MerchantTribeApplication app) { if (p == null) return; if (p.Bvin == string.Empty) return; var model = new SingleProductViewModel(p, app); RenderModel(sb, model, app); }
private List<SingleProductViewModel> LoadProductGrid(ContentBlock b, MerchantTribeApplication app) { List<SingleProductViewModel> result = new List<SingleProductViewModel>(); List<ContentBlockSettingListItem> myProducts = b.Lists.FindList("ProductGrid"); if (myProducts != null) { int column = 1; if (b != null) { int maxColumns = b.BaseSettings.GetIntegerSetting("GridColumns"); if (maxColumns < 1) maxColumns = 3; // Pull all products in a single db call instead of individual calls List<string> allProductBvins = myProducts.Select(y => y.Setting1).ToList(); List<Product> allProducts = app.CatalogServices.Products.FindMany(allProductBvins); foreach (ContentBlockSettingListItem sett in myProducts) { string bvin = sett.Setting1; Product p = allProducts.Where(y => y.Bvin == bvin).FirstOrDefault(); // app.CatalogServices.Products.Find(bvin); if (p != null) { bool isLastInRow = false; bool isFirstInRow = false; if ((column == 1)) { isFirstInRow = true; } if ((column == maxColumns)) { column = 1; isLastInRow = true; } else { column += 1; } SingleProductViewModel vm = new SingleProductViewModel(p, app); vm.IsFirstItem = isFirstInRow; vm.IsLastItem = isLastInRow; result.Add(vm); } } } } return result; }
public string RenderModel(SingleProductViewModel model, MerchantTribeApplication app) { StringBuilder sb = new StringBuilder(); var productRenderer = new code.TemplateEngine.TagHandlers.SingleProduct(); sb.Append("<div class=\"productrotator\"><div class=\"decoratedblock\"><div class=\"blockcontent\">"); sb.Append(productRenderer.RenderModelToString(model, app)); sb.Append("<div class=\"clear\"></div></div></div></div>"); return sb.ToString(); }
public void RenderSingleModel(StringBuilder sb, SingleProductViewModel model, MerchantTribeApplication app) { sb.Append("<div class=\"record\">"); sb.Append("<div class=\"recordsku\">"); sb.Append("<a href=\"" + model.ProductLink + "\">" + HttpUtility.HtmlEncode(model.Item.Sku) + "</a>"); sb.Append("</div>"); sb.Append("<div class=\"recordname\">"); sb.Append("<a href=\"" + model.ProductLink + "\">" + HttpUtility.HtmlEncode(model.Item.ProductName) + "</a>"); sb.Append("</div>"); sb.Append("<div class=\"recordprice\">"); sb.Append("<a href=\"" + model.ProductLink + "\">" + model.UserPrice.DisplayPrice(true) + "</a>"); sb.Append("</div>"); sb.Append("</div>"); }
private List<SingleProductViewModel> LoadProductGrid(ContentBlock b) { List<SingleProductViewModel> result = new List<SingleProductViewModel>(); List<ContentBlockSettingListItem> myProducts = b.Lists.FindList("ProductGrid"); if (myProducts != null) { int column = 1; if (b != null) { int maxColumns = b.BaseSettings.GetIntegerSetting("GridColumns"); if (maxColumns < 1) maxColumns = 3; foreach (ContentBlockSettingListItem sett in myProducts) { string bvin = sett.Setting1; Product p = MTApp.CatalogServices.Products.Find(bvin); if (p != null) { bool isLastInRow = false; bool isFirstInRow = false; if ((column == 1)) { isFirstInRow = true; } if ((column == maxColumns)) { column = 1; isLastInRow = true; } else { column += 1; } SingleProductViewModel vm = new SingleProductViewModel(p, MTApp); vm.IsFirstItem = isFirstInRow; vm.IsLastItem = isLastInRow; result.Add(vm); } } } } return result; }
private void RenderSingleModel(StringBuilder sb, SingleProductViewModel model, MerchantTribeApplication app, string buttonDetails, string buttonAdd) { sb.Append("<div class=\"record\">"); // Image sb.Append("<div class=\"recordimage\">"); sb.Append("<a href=\"" + model.ProductLink + "\">"); sb.Append("<img src=\"" + model.ImageUrl + "\" border=\"0\" alt=\"" + HttpUtility.HtmlEncode(model.Item.ImageFileMediumAlternateText) + "\" /></a>"); sb.Append("</div>"); // SKU sb.Append("<div class=\"recordsku\">"); sb.Append("<a href=\"" + model.ProductLink + "\">" + HttpUtility.HtmlEncode(model.Item.Sku) + "</a>"); sb.Append("</div>"); // Name sb.Append("<div class=\"recordname\">"); sb.Append("<a href=\"" + model.ProductLink + "\">" + HttpUtility.HtmlEncode(model.Item.ProductName) + "</a>"); sb.Append("</div>"); // Description sb.Append("<div class=\"recordshortdescription\">"); sb.Append(model.Item.LongDescription); sb.Append("</div>"); // Price sb.Append("<div class=\"recordprice\">"); sb.Append("<a href=\"" + model.ProductLink + "\">" + model.UserPrice.DisplayPrice(true) + "</a>"); sb.Append("</div>"); // Controls sb.Append("<div class=\"recordcontrols\">"); if (model.Item.HasOptions() == true) { sb.Append("<a href=\"" + model.ProductLink + "\"><img src=\"" + buttonDetails + "\" alt=\"View Product\" /></a>"); } else { sb.Append("<a href=\"" + app.CurrentRequestContext.UrlHelper.Content("~/cart?quickaddsku=" + HttpUtility.UrlEncode(model.Item.Sku)) + "\"><img src=\"" + buttonAdd + "\" alt=\"View Product\" /></a>"); } sb.Append("</div>"); sb.Append("</div>"); }
public string Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block) { Product p = null; List<ContentBlockSettingListItem> myProducts = block.Lists.FindList("Products"); if (myProducts != null) { if (myProducts.Count > 0) { int displayIndex = GetProductIndex(myProducts.Count - 1); ContentBlockSettingListItem data = myProducts[displayIndex]; string bvin = data.Setting1; p = app.CatalogServices.Products.Find(bvin); } } if (p != null) { SingleProductViewModel model = new SingleProductViewModel(p, app); return RenderModel(model, app); } return string.Empty; }
private void LoadRelatedItems(ProductPageViewModel model) { int MaxItemsToShow = 3; bool IncludeAutoSuggestions = true; List<ProductRelationship> relatedItems = MTApp.CatalogServices.ProductRelationships.FindForProduct(model.LocalProduct.Bvin); if (relatedItems == null) return; int maxItems = MaxItemsToShow; // we have fewer available than max to show if (relatedItems.Count < MaxItemsToShow) { if (IncludeAutoSuggestions) { // try to fill in auto suggestions int toAuto = MaxItemsToShow - relatedItems.Count; List<ProductRelationship> autos = MTApp.GetAutoSuggestedRelatedItems(model.LocalProduct.Bvin, toAuto); if (autos != null) { foreach (ProductRelationship r in autos) { relatedItems.Add(r); } } } maxItems = relatedItems.Count; } if (relatedItems.Count < 1) return; for (int i = 0; i < maxItems; i++) { string relatedBvin = relatedItems[i].RelatedProductId; Product related = MTApp.CatalogServices.Products.Find(relatedBvin); if (related != null) { SingleProductViewModel item = new SingleProductViewModel(related, MTApp); if (i == 0) item.IsFirstItem = true; if (i == (maxItems - 1)) item.IsLastItem = true; model.RelatedItems.Add(item); } } }
public ActionResult RenderSingleProduct(Product product) { if (product == null) return Content(""); SingleProductViewModel model = new SingleProductViewModel(product, MTApp); return View(model); }
public ProductReviewsViewModel() { ProductView = new SingleProductViewModel(); Reviews =new List<ProductReview>(); }
protected List<SingleProductViewModel> PrepProducts(List<Product> products, int columns, MerchantTribeApplication app) { var profiler = MiniProfiler.Current; using (profiler.Step("Prepping Products")) { List<SingleProductViewModel> result = new List<SingleProductViewModel>(); int columnCount = 1; foreach (Product p in products) { SingleProductViewModel model = new SingleProductViewModel(p, app); bool isLastInRow = false; bool isFirstInRow = false; if ((columnCount == 1)) { isFirstInRow = true; } if ((columnCount == columns)) { isLastInRow = true; columnCount = 1; } else { columnCount += 1; } model.IsFirstItem = isFirstInRow; model.IsLastItem = isLastInRow; result.Add(model); } return result; } }
public ProductReviewsViewModel() { ProductView = new SingleProductViewModel(); Reviews = new List <ProductReview>(); }
public string RenderModelToString(SingleProductViewModel model, MerchantTribeApplication app) { StringBuilder sb = new StringBuilder(); RenderModel(sb, model, app); return sb.ToString(); }
public SavedItemViewModel() { this.SavedItem = new WishListItem(); this.FullProduct = new SingleProductViewModel(); }