Last active
February 13, 2020 10:00
-
-
Save brianweet/4eb4a0499830682d7db45247fbf6d244 to your computer and use it in GitHub Desktop.
BynderAssetMetaDataMapper.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using Bynder.ContentTypes; | |
using Newtonsoft.Json.Linq; | |
namespace Bynder | |
{ | |
// This is the default metadata mapper, you can use it as a base class or replace it | |
public class BynderAssetMetaDataMapper : IBynderAssetMetaDataMapper | |
{ | |
public virtual BynderAssetData MapMetaData(BynderAssetData bynderAsset, Dictionary<string, JToken> dictionary) | |
{ | |
if (dictionary == null || dictionary.Count == 0) | |
{ | |
return bynderAsset; | |
} | |
bynderAsset.UserCreated = dictionary.GetValue<string>("userCreated"); | |
bynderAsset.MarkedAsArchived = dictionary.GetValue<bool>("archive"); | |
bynderAsset.ShowWatermark = dictionary.GetValue<bool>("watermarked"); | |
bynderAsset.LimitedUsage = dictionary.GetValue<bool>("limited"); | |
bynderAsset.Views = dictionary.GetValue<int>("views"); | |
bynderAsset.Downloads = dictionary.GetValue<int>("downloads"); | |
bynderAsset.DatePublished = dictionary.GetValue<DateTime>("datePublished"); | |
// Here you would map the new 'SEO name' field, which you can then use in the view to render the asset | |
return bynderAsset; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment