private Asset CreateAsset(Album album, string fileName) { var extension = fileName.Split('.')[1]; if (album != null && album.IsProfilePictureAlbum) { //if the profile pic album, delete all images before saving to int i = album.Assets.Count - 1; while (album.Assets.Count > 0) { DataContext.Assets.DeleteObject(album.Assets.ElementAt(i)); i--; } DataContext.SaveChanges(); } var asset = new Asset() { Album = album, Type = extension.ToLower() }; DataContext.Assets.AddObject(asset); DataContext.SaveChanges(); return asset; }
protected void Page_Load(object sender, EventArgs e) { var assetId = Request.QueryString["Id"]; _asset = LoadAsset(long.Parse(assetId)); AssetRender.Asset = _asset; AssetRender.DataBind(); }
private Asset CreateAsset(Album album, string fileName) { var extension = fileName.Split('.')[1]; var asset = new Asset() { Album = album, Type = extension }; DataContext.Assets.AddObject(asset); DataContext.SaveChanges(); return asset; }
/// <summary> /// Create a new Asset object. /// </summary> /// <param name="id">Initial value of the ID property.</param> public static Asset CreateAsset(global::System.Int64 id) { Asset asset = new Asset(); asset.ID = id; return asset; }
/// <summary> /// Deprecated Method for adding a new object to the Assets EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToAssets(Asset asset) { base.AddObject("Assets", asset); }
private string BuildAssetPath(Asset asset) { return string.Format("/{0}/{1}", ASSET_FOLDER_PATH, asset.ID); }
public void SaveAsset(Asset asset, Stream assetData) { var assetPath = BuildAssetPath(asset); var fileStream = new FileStream(_context.Server.MapPath(assetPath), FileMode.OpenOrCreate); assetData.CopyTo(fileStream); }
public Stream GetAssetData(Asset asset) { var assetPath = BuildAssetPath(asset); var reader = new StreamReader(_context.Server.MapPath(assetPath)); return reader.BaseStream; }
public void Delete(Asset asset) { var assetPath = BuildAssetPath(asset); File.Delete(_context.Server.MapPath(assetPath)); }
private void DeleteAsset(Asset asset) { DataContext.Assets.DeleteObject(asset); return; }