Пример #1
0
        public ActionResult AddImageToGallery(int galleryId, FormCollection form, HttpPostedFileBase fileUpload)
        {
            using (var context = new ContentStorage())
            {
                var galleryItem = new Galleryitem();
                TryUpdateModel(galleryItem, new[] { "SortOrder" });
                string fileName = IOHelper.GetUniqueFileName("~/Content/Photos", fileUpload.FileName);
                string filePath = Server.MapPath("~/Content/Photos");
                filePath = Path.Combine(filePath, fileName);
                fileUpload.SaveAs(filePath);

                galleryItem.ImageSource = fileName;

                var gallery = context.Gallery.Where(g => g.Id == galleryId).First();

                gallery.GalleryItems.Add(galleryItem);

                context.SaveChanges();


                return RedirectToAction("Details", "Gallery", new {Area = "", id = gallery.Name});
            }
        }
Пример #2
0
 /// <summary>
 /// Create a new Galleryitem object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="sortOrder">Initial value of the SortOrder property.</param>
 public static Galleryitem CreateGalleryitem(global::System.Int32 id, global::System.Int32 sortOrder)
 {
     Galleryitem galleryitem = new Galleryitem();
     galleryitem.Id = id;
     galleryitem.SortOrder = sortOrder;
     return galleryitem;
 }
Пример #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Galleryitem EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToGalleryitem(Galleryitem galleryitem)
 {
     base.AddObject("Galleryitem", galleryitem);
 }