public static domainModels.ThemeAsset ToDomainModel(this webModels.ThemeAsset item) { var retVal = new domainModels.ThemeAsset(); if (item.ByteContent != null) retVal.ByteContent = item.ByteContent; else if (!string.IsNullOrEmpty(item.Content)) retVal.ByteContent = Encoding.UTF8.GetBytes(item.Content); retVal.AssetUrl = item.AssetUrl; retVal.Id = item.Id; retVal.ContentType = item.ContentType; retVal.AssetName = item.Name; return retVal; }
public static domainModels.ThemeAsset ToDomainModel(this webModels.ThemeAsset item) { var retVal = new domainModels.ThemeAsset(); if (item.ByteContent != null) { retVal.ByteContent = item.ByteContent; } else if (!string.IsNullOrEmpty(item.Content)) { retVal.ByteContent = Encoding.UTF8.GetBytes(item.Content); } retVal.AssetUrl = item.AssetUrl; retVal.Id = item.Id; retVal.ContentType = item.ContentType; retVal.AssetName = item.Name; return(retVal); }
public static webModels.ThemeAsset ToWebModel(this domainModels.ThemeAsset item, bool loadContent = true) { var retVal = new webModels.ThemeAsset(); if (loadContent) { if (ContentTypeUtility.IsImageContentType(item.ContentType)) { if (item.ByteContent != null) { //retVal.Content = ContentTypeUtility.ConvertImageToBase64String(item.ByteContent, item.ContentType); retVal.ByteContent = item.ByteContent; } else { retVal.Content = retVal.AssetUrl = item.AssetUrl; } } else if (ContentTypeUtility.IsTextContentType(item.ContentType)) { if (item.ByteContent != null) { retVal.Content = Encoding.UTF8.GetString(item.ByteContent); } } else // treat as a binary file for now { if (item.ByteContent != null) { retVal.ByteContent = item.ByteContent; } } } retVal.Id = item.Id; retVal.ContentType = item.ContentType; retVal.Updated = item.Updated; retVal.Name = string.Join("/", item.Id.Split('/').AsEnumerable().Skip(1)); return(retVal); }
public async Task UploadTheme(string storeId, string themeName, System.IO.Compression.ZipArchive archive) { foreach (ZipArchiveEntry entry in archive.Entries) { if (!IsFolder(entry)) { using (var stream = entry.Open()) { var asset = new ThemeAsset { AssetName = PrepareAssetNameAndId(entry.FullName), Id = PrepareAssetNameAndId(entry.FullName) }; var arr = ReadFully(stream); asset.ByteContent = arr; asset.ContentType = ContentTypeUtility.GetContentType(entry.FullName, arr); await SaveThemeAsset(storeId, themeName.Trim('/'), asset); } } } }
public static ThemeAsset AsThemeAsset(this ContentItem item) { var retVal = new ThemeAsset { Id = item.Path, ByteContent = item.ByteContent, ContentType = item.ContentType, Updated = item.ModifiedDate.HasValue ? RemoveMilliseconds(item.ModifiedDate.Value) : RemoveMilliseconds(item.CreatedDate) }; return retVal; }
public static ThemeAsset AsThemeAsset(this ContentItem item) { var retVal = new ThemeAsset { Id = item.Path, ByteContent = item.ByteContent, ContentType = item.ContentType, Updated = item.ModifiedDate.HasValue ? item.ModifiedDate.Value : item.CreatedDate }; return retVal; }
private string GetStoreIdForThemeAsset(coreModels.ThemeAsset themeAsset) { return(themeAsset.Path.Split(new char[] { '/' })[0]); }