コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString.AllKeys.Contains("action"))
            {
                // Action
                switch (Request["action"])
                {
                    case "upload":
                        HttpPostedFile file = Request.Files[0];
                        Data.Asset asset = new Data.Asset();
                        asset.path = "\\";
                        asset.mimeType = file.ContentType;
                        asset.type = int.Parse(Request["type"]);
                        asset.name = Request["name"];
                        HurricaneEntities db = new HurricaneEntities();
                        db.AddToAssets(asset);
                        db.SaveChanges();
                        file.SaveAs(Properties.Settings.Default.AssetPath + asset.path + asset.id.ToString());

                        break;
                    case "edit":
                        break;
                    case "delete":
                        break;
                }
                Response.Redirect("AssetManager.aspx");
            }
            else
            {
                // Display
                HurricaneEntities db = new HurricaneEntities();
                List<Data.Asset> assets = db.Assets.ToList();
                rptAssets.DataSource = assets;
                rptAssets.DataBind();

            }
        }
コード例 #2
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);
 }
コード例 #3
0
 /// <summary>
 /// Create a new Asset object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 /// <param name="name">Initial value of the name property.</param>
 /// <param name="type">Initial value of the type property.</param>
 /// <param name="path">Initial value of the path property.</param>
 public static Asset CreateAsset(global::System.Int32 id, global::System.String name, global::System.Int32 type, global::System.String path)
 {
     Asset asset = new Asset();
     asset.id = id;
     asset.name = name;
     asset.type = type;
     asset.path = path;
     return asset;
 }