protected string GetValueText(ReferenceInfoDto referenceInfo, int subitemId) { if (referenceInfo.ValuesDic.ContainsKey(subitemId)) { return(referenceInfo.ValuesDic[subitemId].ValueText); } SubitemInfoDto subitem = GetSubitemInfo(subitemId); return(subitem != null ? subitem.DefaultValue : null); }
public override void Populate(ReferenceInfoDto referenceInfo) { if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.PhotoList.Title)) { Title = referenceInfo.ValuesDic[BlockRegister.PhotoList.Title].ValueText; } SubitemInfoDto subitem = BlockInfo.Subitems.SingleOrDefault(o => object.Equals(o.SubitemId, BlockRegister.PhotoList.PhotosGrid)); object photoGridId = null; if (subitem != null && subitem.Grid != null) { photoGridId = subitem.Grid.Id; } if (referenceInfo.GridRows != null) { int index = 0; foreach (GridRowDto row in referenceInfo.GridRows.Where(o => object.Equals(o.GridId, photoGridId))) { Photo item = new Photo(); Items.Add(item); item.Index = index++; item.Credit = string.Empty; DucValueDto valueTitle = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.PhotoGrid.Col_Title)); if (valueTitle != null) { item.Title = valueTitle.ValueText; } DucValueDto valueSubTitle = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.PhotoGrid.Col_Subtitle)); if (valueSubTitle != null) { item.Subtitle = valueSubTitle.ValueText; } DucValueDto valueAbstract = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.PhotoGrid.Col_Abstract)); if (valueAbstract != null) { item.Abstract = valueAbstract.ValueText; } DucValueDto valueImage = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.PhotoGrid.Col_Image)); if (valueImage != null) { item.ImageUrl = valueImage.ValueUrl; } } } }
public override void Populate(ReferenceInfoDto referenceInfo) { if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.RecipeBlock.Name)) { Recipe.Name = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.Name].ValueText; } if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.RecipeBlock.Subtitle)) { Recipe.Subtitle = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.Subtitle].ValueText; } if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.RecipeBlock.Image)) { Recipe.ImageUrl = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.Image].ValueUrl; Recipe.ImageText = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.Image].ValueText; } if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.RecipeBlock.Abstract)) { Recipe.Abstract = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.Abstract].ValueText; } if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.RecipeBlock.Tips)) { Recipe.Tips = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.Tips].ValueHtml; } if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.RecipeBlock.PrepareTime)) { Recipe.PrepareTimeMinutes = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.PrepareTime].ValueInt; } if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.RecipeBlock.CookTime)) { Recipe.CookTimeMinutes = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.CookTime].ValueInt; } if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.RecipeBlock.Servings)) { Recipe.Servings = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.Servings].ValueInt; } SubitemInfoDto ingredientSubitem = BlockInfo.Subitems.SingleOrDefault(o => object.Equals(o.SubitemId, BlockRegister.RecipeBlock.IngredientGrid)); object ingredientGridId = null; if (ingredientSubitem != null && ingredientSubitem.Grid != null) { ingredientGridId = ingredientSubitem.Grid.Id; } SubitemInfoDto instructionSubitem = BlockInfo.Subitems.SingleOrDefault(o => object.Equals(o.SubitemId, BlockRegister.RecipeBlock.InstructionGrid)); object instructionGridId = null; if (instructionSubitem != null && instructionSubitem.Grid != null) { instructionGridId = instructionSubitem.Grid.Id; } if (referenceInfo.GridRows != null) { foreach (GridRowDto row in referenceInfo.GridRows.Where(o => object.Equals(o.GridId, ingredientGridId))) { RecipeIngredient item = new RecipeIngredient(); Recipe.RecipeIngredients.Add(item); DucValueDto valueOrder = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.RecipeIngredientGrid.Col_Sortorder)); if (valueOrder != null) { item.Sortorder = valueOrder.ValueInt.HasValue ? valueOrder.ValueInt.Value : 0; } DucValueDto valueIngredientName = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.RecipeIngredientGrid.Col_IngredientName)); if (valueIngredientName != null) { item.IngredientName = valueIngredientName.ValueText; } DucValueDto valueQuantity = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.RecipeIngredientGrid.Col_Quantity)); if (valueQuantity != null) { item.Quantity = valueQuantity.ValueText; } DucValueDto valueUnitOfMeasure = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.RecipeIngredientGrid.Col_UnitOfMeasure)); if (valueUnitOfMeasure != null) { item.UnitOfMeasure = valueUnitOfMeasure.ValueText; } } foreach (GridRowDto row in referenceInfo.GridRows.Where(o => object.Equals(o.GridId, instructionGridId))) { RecipeInstruction item = new RecipeInstruction(); Recipe.RecipeInstructions.Add(item); DucValueDto valueOrder = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.RecipeInstructionGrid.Col_Sortorder)); if (valueOrder != null) { item.Sortorder = valueOrder.ValueInt.HasValue ? valueOrder.ValueInt.Value : 0; } DucValueDto valueDescription = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.RecipeInstructionGrid.Col_Description)); if (valueDescription != null) { item.Description = valueDescription.ValueText; } } } // Keyword view model TagsViewModel = new ReferenceKeywordsViewModel(referenceInfo); SocialShareBarViewModel = new SocialShareBarViewModel(RequestedUrl.AbsoluteUri, Recipe.Name, Recipe.ImageUrl); }
public override void Populate(ReferenceInfoDto referenceInfo) { if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.PhotoGallery.Title)) { Gallery.Title = referenceInfo.ValuesDic[BlockRegister.PhotoGallery.Title].ValueText; } if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.PhotoGallery.Subtitle)) { Gallery.Subtitle = referenceInfo.ValuesDic[BlockRegister.PhotoGallery.Subtitle].ValueText; } if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.PhotoGallery.Abstract)) { Gallery.Abstract = referenceInfo.ValuesDic[BlockRegister.PhotoGallery.Abstract].ValueText; } if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.PhotoGallery.ThumbnailUrl)) { Gallery.ThumbnailUrl = referenceInfo.ValuesDic[BlockRegister.PhotoGallery.ThumbnailUrl].ValueUrl; } if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.PhotoGallery.RelatedGalleryList)) { DucValueDto value = referenceInfo.ValuesDic[BlockRegister.PhotoGallery.RelatedGalleryList]; // Exclude current reference Gallery.RelatedGalleries = value.AttachedSubjects.Where(o => !object.Equals(o.ReferenceId, referenceInfo.ReferenceId)).ToList(); } SubitemInfoDto subitem = BlockInfo.Subitems.SingleOrDefault(o => object.Equals(o.SubitemId, BlockRegister.PhotoGallery.PhotosGrid)); object photoGridId = null; if (subitem != null && subitem.Grid != null) { photoGridId = subitem.Grid.Id; } if (referenceInfo.GridRows != null) { int index = 0; foreach (GridRowDto row in referenceInfo.GridRows.Where(o => object.Equals(o.GridId, photoGridId))) { Photo item = new Photo(); Gallery.Items.Add(item); item.Index = index++; item.Credit = string.Empty; DucValueDto valueTitle = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.PhotoGrid.Col_Title)); if (valueTitle != null) { item.Title = valueTitle.ValueText; } DucValueDto valueSubTitle = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.PhotoGrid.Col_Subtitle)); if (valueSubTitle != null) { item.Subtitle = valueSubTitle.ValueText; } DucValueDto valueAbstract = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.PhotoGrid.Col_Abstract)); if (valueAbstract != null) { item.Abstract = valueAbstract.ValueText; } DucValueDto valueImage = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.PhotoGrid.Col_Image)); if (valueImage != null) { item.ImageUrl = valueImage.ValueUrl; } } } HasValue = Gallery.Title.TrimHasValue() || Gallery.Abstract.TrimHasValue() || Gallery.ThumbnailUrl.TrimHasValue() || Gallery.Items.Count > 0; }