Exemplo n.º 1
0
 public static AdsDataComponent.PhotosDataTable GetPhotosByAdId(int adId)
 {
     using (PhotosDataAdapter db = new PhotosDataAdapter())
     {
         return db.GetPhotosByAdId(adId);
     }
 }
Exemplo n.º 2
0
 public static byte[] GetPhotoBytesById(int photoId, PhotoSize size)
 {
     using (PhotosDataAdapter db = new PhotosDataAdapter())
     {
         return db.GetPhotoBytesById(photoId, (int)size) as byte[];
     }
 }
Exemplo n.º 3
0
        public static int InsertPhoto(int adId, byte[] bytesFull, byte[] bytesMedium, byte[] bytesSmall, bool useAsPreview)
        {
            int photoId = -1;
            if (bytesFull != null && bytesMedium != null && bytesSmall != null)
            {
                SiteSettings s = SiteSettings.GetSharedSettings();
                using (PhotosDataAdapter db = new PhotosDataAdapter())
                {
                    if (s.StorePhotosInDatabase)
                        photoId = Convert.ToInt32(db.InsertPhoto(adId, bytesFull, bytesMedium, bytesSmall, useAsPreview, DateTime.Now));
                    else
                    {
                        photoId = Convert.ToInt32(db.InsertPhoto(adId, null, null, null, useAsPreview, DateTime.Now));

                        string fullSizePath = GetFilePath(photoId, false, PhotoSize.Full);
                        string mediumSizePath = GetFilePath(photoId, false, PhotoSize.Medium);
                        string smallSizePath = GetFilePath(photoId, false, PhotoSize.Small);

                        WriteToFile(fullSizePath, bytesFull);
                        WriteToFile(mediumSizePath, bytesMedium);
                        WriteToFile(smallSizePath, bytesSmall);

                    }
                }
            }
            return photoId;
        }
Exemplo n.º 4
0
 public static void SetAdPreviewPhoto(int adId, int photoId)
 {
     using (PhotosDataAdapter db = new PhotosDataAdapter())
     {
         db.SetAdPreviewPhoto(photoId, adId);
     }
 }
Exemplo n.º 5
0
        public static void RemovePhotosOfDeletedAds()
        {
            SiteSettings s = SiteSettings.GetSharedSettings();

            // must remove photos from file system before removing from DB
            using (PhotosDataAdapter db = new PhotosDataAdapter())
            {
                if (s.StorePhotosInDatabase)
                {
                    AdsDataComponent.PhotosDataTable deletedAdPhotos = db.GetPhotosByAdStatus((int)AdStatus.Deleted);
                    RemovePhotoFilesInTable(deletedAdPhotos);
                }

                db.RemovePhotosByAdStatus((int)AdStatus.Deleted);
            }
        }
Exemplo n.º 6
0
 public static void RemovePhotosByAdId(int adId)
 {
     SiteSettings s = SiteSettings.GetSharedSettings();
     using (PhotosDataAdapter db = new PhotosDataAdapter())
     {
         if (s.StorePhotosInDatabase)
         {
             AdsDataComponent.PhotosDataTable photos = db.GetPhotosByAdStatus((int)AdStatus.Deleted);
             RemovePhotoFilesInTable(photos);
         }
     }
 }
Exemplo n.º 7
0
        public static bool RemovePhotoById(int id)
        {
            bool result = false;

            using (PhotosDataAdapter db = new PhotosDataAdapter())
            {
                db.RemovePhoto(id);
            }

            SiteSettings s = SiteSettings.GetSharedSettings();
            if (s.StorePhotosInDatabase)
            {
                result = true;
            }
            {
                result = DeleteLocalPhotoFiles(id);
            }

            return result;
        }