Ejemplo n.º 1
0
 public async Task <IActionResult> SaveMeta(MediaListModel.MediaItem model)
 {
     if (await _service.SaveMeta(model))
     {
         return(Ok(new StatusMessage
         {
             Type = StatusMessage.Success,
             Body = _localizer.Media["The meta information was succesfully updated"]
         }));
     }
     else
     {
         return(Ok(new StatusMessage
         {
             Type = StatusMessage.Error,
             Body = _localizer.Media["An error occured when updating the meta information"]
         }));
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Saves the updated meta information for the given media asset.
        /// </summary>
        /// <param name="media">The media asset</param>
        /// <returns>If the meta information was updated successful</returns>
        public async Task <bool> SaveMeta(MediaListModel.MediaItem media)
        {
            var model = await _api.Media.GetByIdAsync(media.Id);

            if (model != null)
            {
                // Only update the meta fields
                model.Title       = media.Title;
                model.AltText     = media.AltText;
                model.Description = media.Description;

                foreach (var property in media.Properties)
                {
                    model.Properties[property.Key] = property.Value;
                }

                await _api.Media.SaveAsync(model);

                return(true);
            }
            return(false);
        }