Exemple #1
0
        /// <summary>
        /// Populates the Place object's properties from the given content view.
        /// </summary>
        /// <param name="thisObject">Place object</param>
        /// <param name="contentsView">content view object</param>
        /// <returns>Place instance</returns>
        public static Place SetValuesFrom(this Place thisObject, ContentsView contentsView)
        {
            if (contentsView != null)
            {
                if (thisObject == null)
                {
                    thisObject = new Place();
                }

                thisObject.Name           = contentsView.Title;
                thisObject.MSRComponentId = contentsView.ContentID;

                thisObject.FileType       = contentsView.TypeID.ToEnum <int, ContentTypes>(ContentTypes.Generic);
                thisObject.ContentLink    = thisObject.FileType == ContentTypes.Link ? contentsView.ContentUrl : string.Empty;
                thisObject.ContentAzureID = thisObject.FileType == ContentTypes.Link ? string.Empty : contentsView.ContentAzureID.ToString();

                thisObject.Url       = contentsView.Filename;
                thisObject.Thumbnail = (contentsView.ThumbnailID.HasValue && contentsView.ThumbnailID != Guid.Empty) ? contentsView.ThumbnailID.ToString() : null;

                // Permissions for Content view are hard-coded to Read as it is used for browse
                thisObject.Permission = Permission.Reader;
            }

            return(thisObject);
        }
Exemple #2
0
        /// <summary>
        /// Populates the Tour object's properties from the given content view.
        /// </summary>
        /// <param name="thisObject">Tour object</param>
        /// <param name="contentsView">content view object</param>
        /// <returns>Tour instance</returns>
        public static TourModel SetValuesFrom(this TourModel thisObject, ContentsView contentsView)
        {
            if (contentsView != null)
            {
                if (thisObject == null)
                {
                    thisObject = new TourModel();
                }

                thisObject.Title          = contentsView.Title;
                thisObject.TourUrl        = contentsView.ContentAzureID.ToString();
                thisObject.ID             = contentsView.ContentAzureID.ToString();
                thisObject.MSRComponentId = contentsView.ContentID;
                thisObject.Description    = contentsView.Description;
                thisObject.Author         = contentsView.DistributedBy;
                thisObject.ThumbnailUrl   = (contentsView.ThumbnailID.HasValue && contentsView.ThumbnailID != Guid.Empty) ? contentsView.ThumbnailID.ToString() : null;
                thisObject.LengthInSecs   = contentsView.TourRunLength;
                thisObject.AverageRating  = contentsView.AverageRating.HasValue ? contentsView.AverageRating.ToString() : "0";

                // Permissions for Content view are hard-coded to Read as it is used for browse
                thisObject.Permission = Permission.Reader;
            }

            return(thisObject);
        }
Exemple #3
0
        /// <summary>
        /// Populates the EntityViewModel object's properties from the given ContentsView object's properties.
        /// </summary>
        /// <param name="thisObject">Current entity view model on which the extension method is called</param>
        /// <param name="content">ContentsView model from which values to be read</param>
        /// <returns>Values populated EntityViewModel instance</returns>
        public static DeepZoomViewModel SetValuesFrom(this DeepZoomViewModel thisObject, ContentsView content)
        {
            if (content != null)
            {
                if (thisObject == null)
                {
                    thisObject = new DeepZoomViewModel();
                }

                thisObject.Id            = content.ContentID;
                thisObject.Description   = content.Description;
                thisObject.LastUpdated   = Convert.ToDateTime(content.LastUpdatedDatetime, CultureInfo.CurrentCulture).ToString("s", CultureInfo.CurrentCulture);
                thisObject.DistributedBy = content.DistributedBy;

                thisObject.Tags           = content.Tags != null ? content.Tags : string.Empty;
                thisObject.Citation       = content.Citation;
                thisObject.FileType       = content.TypeID.ToEnum <int, ContentTypes>(ContentTypes.Generic);
                thisObject.ContentLink    = thisObject.FileType == ContentTypes.Link ? content.ContentUrl : string.Empty;
                thisObject.ContentAzureID = thisObject.FileType == ContentTypes.Link ? Guid.Empty : content.ContentAzureID;

                thisObject.Name     = content.Title;
                thisObject.Category = content.CategoryID.ToEnum <int, CategoryType>(CategoryType.All);
                thisObject.Entity   = EntityType.Content;

                thisObject.Rating         = content.AverageRating.HasValue ? (double)content.AverageRating : 0;
                thisObject.ThumbnailID    = content.ThumbnailID;
                thisObject.ContentAzureID = content.ContentAzureID;
                thisObject.FileName       = content.Filename;
            }

            return(thisObject);
        }