public void Save()
        {
            using (PhotoGalleryDataContext db = PhotoGalleryDataContext.GetDataContext()) {
                tblGalleryImage gal = (from c in db.tblGalleryImages
                                       where c.GalleryImageID == this.GalleryImageID
                                       select c).FirstOrDefault();

                if (gal == null || this.GalleryID == Guid.Empty)
                {
                    gal                = new tblGalleryImage();
                    gal.GalleryID      = this.GalleryID;
                    gal.GalleryImageID = Guid.NewGuid();
                }

                gal.GalleryImage = this.GalleryImage;
                gal.ImageOrder   = this.ImageOrder;

                if (gal.GalleryImageID != this.GalleryImageID)
                {
                    db.tblGalleryImages.InsertOnSubmit(gal);
                }

                db.SubmitChanges();

                this.GalleryImageID = gal.GalleryImageID;
            }
        }
Exemple #2
0
        public void Save()
        {
            if (!String.IsNullOrEmpty(this.GalleryImage))
            {
                using (PhotoGalleryDataContext db = PhotoGalleryDataContext.GetDataContext()) {
                    tblGalleryImageMeta gal = (from c in db.tblGalleryImageMetas
                                               where c.GalleryImage.ToLower() == this.GalleryImage.ToLower()
                                               select c).FirstOrDefault();

                    if (gal == null || this.GalleryImageMetaID == Guid.Empty)
                    {
                        gal                    = new tblGalleryImageMeta();
                        gal.SiteID             = this.SiteID;
                        gal.GalleryImageMetaID = Guid.NewGuid();
                        gal.GalleryImage       = this.GalleryImage;
                    }

                    gal.ImageTitle    = this.ImageTitle;
                    gal.ImageMetaData = this.ImageMetaData;

                    if (gal.GalleryImageMetaID != this.GalleryImageMetaID)
                    {
                        db.tblGalleryImageMetas.InsertOnSubmit(gal);
                    }

                    db.SubmitChanges();

                    this.GalleryImageMetaID = gal.GalleryImageMetaID;
                }
            }
        }
Exemple #3
0
        public void GalleryImageCleanup(Guid galleryID, List <string> lst)
        {
            using (PhotoGalleryDataContext db = PhotoGalleryDataContext.GetDataContext()) {
                var lstDel = (from g in db.tblGalleryImages
                              where g.GalleryID == galleryID &&
                              !lst.Contains(g.GalleryImage.ToLower())
                              select g).ToList();

                db.tblGalleryImages.DeleteAllOnSubmit(lstDel);

                db.SubmitChanges();
            }
        }