コード例 #1
0
        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;
        }
コード例 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     var assetId = Request.QueryString["Id"];
     _asset = LoadAsset(long.Parse(assetId));
     AssetRender.Asset = _asset;
     AssetRender.DataBind();
 }
コード例 #3
0
 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;
 }
コード例 #4
0
 /// <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;
 }
コード例 #5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Assets EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToAssets(Asset asset)
 {
     base.AddObject("Assets", asset);
 }
コード例 #6
0
 private string BuildAssetPath(Asset asset)
 {
     return string.Format("/{0}/{1}", ASSET_FOLDER_PATH, asset.ID);
 }
コード例 #7
0
 public void SaveAsset(Asset asset, Stream assetData)
 {
     var assetPath = BuildAssetPath(asset);
     var fileStream = new FileStream(_context.Server.MapPath(assetPath), FileMode.OpenOrCreate);
     assetData.CopyTo(fileStream);
 }
コード例 #8
0
 public Stream GetAssetData(Asset asset)
 {
     var assetPath = BuildAssetPath(asset);
     var reader = new StreamReader(_context.Server.MapPath(assetPath));
     return reader.BaseStream;
 }
コード例 #9
0
 public void Delete(Asset asset)
 {
     var assetPath = BuildAssetPath(asset);
     File.Delete(_context.Server.MapPath(assetPath));
 }
コード例 #10
0
 private void DeleteAsset(Asset asset)
 {
     DataContext.Assets.DeleteObject(asset);
     return;
 }