public static RestAsset ToRest(this Asset asset) { RestAsset restAsset = new RestAsset(); restAsset.Id = asset.Id; restAsset.CreatedAt = asset.CreatedAt; restAsset.ModifiedAt = asset.ModifiedAt; restAsset.PublishedAt = asset.PublishedAt; restAsset.Version = asset.Version; restAsset.Name = asset.Name; restAsset.Hash = asset.Hash; restAsset.MimeType = asset.MimeType; restAsset.Size = asset.Size; restAsset.Slug = asset.Slug; restAsset.Alt = asset.Alt; restAsset.Description = asset.Description; if (asset.Folder != null) { restAsset.Folder = asset.Folder.ToRest(); } foreach (var metadata in asset.Metaddata) { restAsset.Metaddata.Add(metadata.Key, JObject.FromObject(metadata.Value)); } return(restAsset); }
public static Asset ToModel(this RestAsset restAsset) { Asset asset = new Asset(); asset.Id = restAsset.Id; asset.CreatedAt = restAsset.CreatedAt; asset.ModifiedAt = restAsset.ModifiedAt; asset.PublishedAt = restAsset.PublishedAt; asset.Version = restAsset.Version; asset.Name = restAsset.Name; asset.Hash = restAsset.Hash; asset.MimeType = restAsset.MimeType; asset.Size = restAsset.Size; asset.Slug = restAsset.Slug; asset.Alt = restAsset.Alt; asset.Description = restAsset.Description; if (restAsset.Folder != null) { asset.Folder = restAsset.Folder.ToModel(); } foreach (var item in restAsset.Metaddata) { asset.SetMetadata((AssetMetadata)item.Value.ToObject(AssetMetadataManager.Default.GetMetadataType(item.Key))); } return(asset); }