/// <summary> /// Populates the PayloadDetails object's properties from the given Content object's properties. /// </summary> /// <param name="thisObject">PayloadDetails object</param> /// <param name="contentDetail">Content Details object</param> /// <returns>PayloadDetails instance</returns> public static PayloadDetails SetValuesFrom(this PayloadDetails thisObject, ContentDetails contentDetail) { if (contentDetail != null) { if (thisObject == null) { thisObject = InitializePayload(); } if (contentDetail.ContentData is FileDetail) { var fileDetail = contentDetail.ContentData as FileDetail; if (contentDetail.ContentData.ContentType == ContentTypes.Tours) { var tour = new TourModel(); tour.SetValuesFrom(contentDetail); thisObject.Tours.Add(tour); } else if (contentDetail.ContentData.ContentType == ContentTypes.Wtml) { var childCollection = new PayloadDetails(); childCollection.Name = contentDetail.Name; childCollection.Id = fileDetail.AzureID.ToString(); childCollection.MSRComponentId = contentDetail.ID; childCollection.Group = "Explorer"; childCollection.IsCollection = true; childCollection.Thumbnail = (contentDetail.Thumbnail != null && contentDetail.Thumbnail.AzureID != Guid.Empty) ? contentDetail.Thumbnail.AzureID.ToString() : null; childCollection.Permission = contentDetail.UserPermission; thisObject.Children.Add(childCollection); } else { var place = new Place(); place.SetValuesFrom(contentDetail); thisObject.Links.Add(place); } } else { var place = new Place(); place.SetValuesFrom(contentDetail); thisObject.Links.Add(place); } } return(thisObject); }
/// <summary> /// Populates the PayloadDetails object's properties from the given collection of ContentsView object's properties. /// </summary> /// <param name="thisObject">PayloadDetails object</param> /// <param name="contents">ContentsView objects</param> /// <returns>PayloadDetails instance</returns> public static PayloadDetails SetValuesFrom(this PayloadDetails thisObject, IEnumerable <ContentsView> contents) { if (contents != null) { if (thisObject == null) { thisObject = InitializePayload(); } foreach (var content in contents) { if (content.Filename.EndsWith(Constants.TourFileExtension, StringComparison.OrdinalIgnoreCase)) { var tour = new TourModel(); tour.SetValuesFrom(content); thisObject.Tours.Add(tour); } else if (content.Filename.EndsWith(Constants.CollectionFileExtension, StringComparison.OrdinalIgnoreCase)) { var childCollection = new PayloadDetails(); childCollection.Name = content.Title; childCollection.Id = content.ContentAzureID.ToString(); childCollection.MSRComponentId = content.ContentID; childCollection.Group = "Explorer"; childCollection.IsCollection = true; childCollection.Thumbnail = (content.ThumbnailID.HasValue && content.ThumbnailID != Guid.Empty) ? content.ThumbnailID.ToString() : null; // Permissions for Content view are hard-coded to Read as it is used for browse childCollection.Permission = Permission.Reader; thisObject.Children.Add(childCollection); } else { var place = new Place(); place.SetValuesFrom(content); thisObject.Links.Add(place); } } } return(thisObject); }