private async Task <ContentCrossSellModel> PopulateContentCrossSellModel(IList <ContentCrossSell> contentCrossSells, ContentCrossSellType type) { var model = new ContentCrossSellModel() { Type = type }; for (var i = 0; i < ContentConstants.CONTENT_CROSS_SELL_LIMIT; i++) { var item = contentCrossSells.SingleOrDefault(x => x.Order == i + 1); var modelItem = item != null ? await PopulateContentCrossSellItemModel(item, type) : new ContentCrossSellItemModel() { Type = type }; model.Items.Add(modelItem); } return(model); }
public async Task <Result <ContentCrossSellModel> > GetContentCrossSells(ContentCrossSellType id) { var contentCrossSells = await contentCrossSellService.GetContentCrossSellsAsync(id); return(await PopulateContentCrossSellModel(contentCrossSells, id)); }
private async Task <ContentCrossSellItemModel> PopulateContentCrossSellItemModel(ContentCrossSell item, ContentCrossSellType type) { var sku = await productService.GetSkuAsync(item.IdSku); if (sku != null) { return(new ContentCrossSellItemModel() { Type = item.Type, Title = item.Title, ImageUrl = item.ImageUrl, IdSku = item.IdSku, Id = item.Id, SkuCode = sku.Code, RetailPrice = sku.Price, WholesalePrice = sku.WholesalePrice }); } else { return(new ContentCrossSellItemModel() { Type = type }); } }