Esempio n. 1
0
 /// <summary>
 /// Removes the given model from cache.
 /// </summary>
 /// <param name="model">The model</param>
 private void RemoveFromCache(Data.Media model)
 {
     if (cache != null)
     {
         cache.Remove(model.Id.ToString());
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Gets the public URL for the given media object.
 /// </summary>
 /// <param name="media">The media</param>
 /// <returns>The public url</returns>
 public string GetPublicUrl(Data.Media media)
 {
     if (media.Id != Guid.Empty)
     {
         return(baseUrl + media.Id + "-" + media.Filename);
     }
     return(null);
 }
Esempio n. 3
0
 /// <summary>
 /// Gets the public URL for the given media object.
 /// </summary>
 /// <param name="media">The media</param>
 /// <returns>The public url</returns>
 public string GetPublicUrl(Data.Media media)
 {
     if (!string.IsNullOrWhiteSpace(media.Id))
     {
         return(baseUrl + media.Id + "-" + media.Filename);
     }
     return(null);
 }
Esempio n. 4
0
        public void MediaFieldConversions()
        {
            var media = new Data.Media()
            {
                Id = Guid.NewGuid()
            };

            Piranha.Extend.Fields.MediaField field = media;
            Assert.Equal(media.Id, field.Id.Value);
        }
Esempio n. 5
0
        /// <summary>
        /// Initializes the field for client use.
        /// </summary>
        /// <param name="api">The current api</param>
        public virtual void Init(IApi api)
        {
            if (Id.HasValue)
            {
                Media = api.Media.GetById(Id.Value);

                if (Media == null)
                {
                    // The image has been removed, remove the
                    // missing id.
                    Id = null;
                }
            }
        }