コード例 #1
0
ファイル: GalleryController.cs プロジェクト: fathurxzz/aleqx
        public ActionResult Add(FormCollection form, HttpPostedFileBase fileUpload)
        {
            using (var context = new ContentStorage())
            {
                var gallery = new Gallery();
                TryUpdateModel(gallery, new[]
                                            {
                                                "Name",
                                                "Title",
                                                "PageTitle",
                                                "SortOrder"
                                            });

                string fileName = IOHelper.GetUniqueFileName("~/Content/Photos", fileUpload.FileName);
                string filePath = Server.MapPath("~/Content/Photos");
                filePath = Path.Combine(filePath, fileName);
                fileUpload.SaveAs(filePath);

                gallery.ImageSource = fileName;

                context.AddToGallery(gallery);
                context.SaveChanges();

                return RedirectToAction("Index", "Gallery", new { Area = ""});
            }
        }
コード例 #2
0
ファイル: Model.Designer.cs プロジェクト: fathurxzz/aleqx
 /// <summary>
 /// Create a new Gallery object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="sortOrder">Initial value of the SortOrder property.</param>
 public static Gallery CreateGallery(global::System.Int32 id, global::System.String name, global::System.Int32 sortOrder)
 {
     Gallery gallery = new Gallery();
     gallery.Id = id;
     gallery.Name = name;
     gallery.SortOrder = sortOrder;
     return gallery;
 }
コード例 #3
0
ファイル: Model.Designer.cs プロジェクト: fathurxzz/aleqx
 /// <summary>
 /// Deprecated Method for adding a new object to the Gallery EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToGallery(Gallery gallery)
 {
     base.AddObject("Gallery", gallery);
 }