예제 #1
0
        public int updateGallery()
        {
            renoRatorDBEntities db = new renoRatorDBEntities();
            Gallery g = db.Galleries.FirstOrDefault(gal => gal.galleryID == this.galleryID);
            if (g == null)
                g = new Gallery();
            int gid = g.galleryID;
            //g.photos = this.photos;
            g.name = this.name;
            if (gid == 0)
                db.AddToGalleries(g);
            db.SaveChanges();
            int newid = g.galleryID;

            foreach (Photo p in this.photos)
            {
                Photo photo = new Photo();
                photo.galleryID = newid;
                photo.path = p.path;
                photo.thumbPath = p.thumbPath;
                photo.description = p.description;
                db.AddToPhotos(photo);
                db.SaveChanges();
            }
            return newid;
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Galleries EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToGalleries(Gallery gallery)
 {
     base.AddObject("Galleries", gallery);
 }
 /// <summary>
 /// Create a new Gallery object.
 /// </summary>
 /// <param name="galleryID">Initial value of the galleryID property.</param>
 public static Gallery CreateGallery(global::System.Int32 galleryID)
 {
     Gallery gallery = new Gallery();
     gallery.galleryID = galleryID;
     return gallery;
 }
 /// <summary>
 /// Create a new Gallery object.
 /// </summary>
 /// <param name="galleryID">Initial value of the galleryID property.</param>
 /// <param name="name">Initial value of the name property.</param>
 public static Gallery CreateGallery(global::System.Int32 galleryID, global::System.String name)
 {
     Gallery gallery = new Gallery();
     gallery.galleryID = galleryID;
     gallery.name = name;
     return gallery;
 }