/// <summary>
        /// Updates the photos in the database
        /// </summary>
        /// <param name="photoID">Id of photo row</param>
        /// <param name="photos">the class containing the resized/new images</param>
        /// <param name="commandText"></param>
        /// <returns></returns>
        public int UpdateImages(int photoID, GalleryPhoto photos, string commandText)
        {
            DbParameter[] parameters =
                {
                    DbClient.MakeParameter("@PhotoID",DbType.Int32,4,photoID),
                    DbClient.MakeParameter("@OriginalImage",DbType.Binary, photos.OriginalImage.Length, photos.OriginalImage),
                    DbClient.MakeParameter("@DisplayImage",DbType.Binary, photos.DisplayImage.Length, photos.DisplayImage),
                    DbClient.MakeParameter("@ThumbnailImage",DbType.Binary, photos.ThumbnailImage.Length, photos.ThumbnailImage)

                };

            int updateCount = DbClient.NonQuery(commandText, parameters);

            return updateCount;
        }
        public void Upload(string token, byte[] image, int galleryId, string imageFormat)
        {
            bool isTokenValid = UserLogic.IsValidToken(token);

            //Check for the validity of the token.
            if (!isTokenValid)
            {
                throw new InvalidTokenException();
            }

            //User user = UserLogic.RetrieveUserByToken(token);
            Photo photo = new Photo { GalleryId = galleryId, Title = string.Empty, DateTaken = DateTime.Now, Description = string.Empty };
            GalleryPhoto galleryphoto = new GalleryPhoto { OriginalImage = image };

            new PhotoLogic().Insert(photo, galleryphoto);
        }
        /// <summary>
        /// Inserts Photo into the Photos Table
        /// </summary>
        /// <param name="photo">A new populated photo.</param>
        /// <param name="galleryPhoto"></param>
        /// <param name="adminPhotos">Photos to be used in admin section</param>
        /// <returns>Insert Count</returns>
        public int Insert(Photo photo, GalleryPhoto galleryPhoto, GalleryPhoto adminPhotos, string commandText)
        {
            DbParameter[] parameters =
            {
                    DbClient.MakeParameter("@Title",DbType.String,100,photo.Title),
                    DbClient.MakeParameter("@Description",DbType.String,255,photo.Description),
                    DbClient.MakeParameter("@DateTaken",DbType.DateTime,8,photo.DateTaken),
                    DbClient.MakeParameter("@GalleryID",DbType.Int32,4,photo.GalleryID),
                    DbClient.MakeParameter("@OriginalImage",DbType.Binary, galleryPhoto.OriginalImage.Length, galleryPhoto.OriginalImage),
                    DbClient.MakeParameter("@DisplayImage",DbType.Binary, galleryPhoto.DisplayImage.Length, galleryPhoto.DisplayImage),
                    DbClient.MakeParameter("@ThumbnailImage",DbType.Binary, galleryPhoto.ThumbnailImage.Length, galleryPhoto.ThumbnailImage),
                    DbClient.MakeParameter("@AdminThumbnail",DbType.Binary, adminPhotos.ThumbnailImage.Length, adminPhotos.ThumbnailImage),
                    DbClient.MakeParameter("@AdminFullsizeImage",DbType.Binary, adminPhotos.DisplayImage.Length, adminPhotos.DisplayImage),
                    DbClient.MakeParameter("@Profile",DbType.String, 50, photo.Profile)

            };

            return DbClient.NonQuery(commandText, parameters);
        }
        /// <summary>
        /// Inserts the specified photo.
        /// </summary>
        /// <param name="photo">The photo.</param>
        /// <param name="galleryPhoto">The gallery photo.</param>
        public void Insert(Photo photo, GalleryPhoto galleryPhoto)
        {
            GalleryPhoto adminPhotos = new GalleryPhoto();

            GallerySettings settings = GallerySettings.Load();
            Bitmap orginalBitmap = ImageConversion.ConvertByteArrayToBitmap(galleryPhoto.OriginalImage);

            //hardcoded administration image dimensions. This will allow the user to change their image sizes and not have it effect my pretty admin layout.
            ImageDimension adminThumbnailDimensions = new ImageDimension { Height = 100, Width = 100 };
            ImageDimension adminFullsizeDimensions = new ImageDimension { Height = 600, Width = 600 };

            adminThumbnailDimensions = FindImagePerspective(orginalBitmap, adminThumbnailDimensions);
            adminFullsizeDimensions = FindImagePerspective(orginalBitmap, adminFullsizeDimensions);

            //Resize the Admin images
            adminPhotos.ThumbnailImage = ImageConversion.Resize(galleryPhoto.OriginalImage, adminThumbnailDimensions);
            adminPhotos.DisplayImage = ImageConversion.Resize(galleryPhoto.OriginalImage, adminFullsizeDimensions);

            //calculate the correct dimensions
            ImageDimension thumbnailDimensions = FindImagePerspective(orginalBitmap, settings.ThumbnailDimensions);
            ImageDimension fullsizeDimensions = FindImagePerspective(orginalBitmap, settings.FullsizeDimensions);

            //Resize the images
            galleryPhoto.ThumbnailImage = ImageConversion.Resize(galleryPhoto.OriginalImage, thumbnailDimensions);
            galleryPhoto.DisplayImage = ImageConversion.Resize(galleryPhoto.OriginalImage, fullsizeDimensions);

            //Set photo profile
            photo.Profile = fullsizeDimensions.PhotoProfile;

            //Insert new images into the Database
            _resource.Insert(photo, galleryPhoto, adminPhotos);
        }
示例#5
0
        /// <summary>
        /// Updates the photos in the database
        /// </summary>
        /// <param name="photoID">Id of photo row</param>
        /// <param name="photos">the class containing the resized/new images</param>
        /// <returns></returns>
        public int UpdateImages(int photoID, GalleryPhoto photos)
        {
            SqlParameter[] parameters =
                {
                    _database.MakeParameter("@PhotoID",SqlDbType.Int,4,photoID),
                    _database.MakeParameter("@OriginalImage",SqlDbType.Image, photos.OriginalImage.Length, photos.OriginalImage),
                    _database.MakeParameter("@DisplayImage",SqlDbType.Image, photos.DisplayImage.Length, photos.DisplayImage),
                    _database.MakeParameter("@ThumbnailImage",SqlDbType.Image, photos.ThumbnailImage.Length, photos.ThumbnailImage)

                };

            int updateCount = _database.NonQuery("Photo_ImagesUpdate", parameters);
            return updateCount;
        }
示例#6
0
        /// <summary>
        /// Inserts Photo into the Photos Table
        /// </summary>
        /// <param name="photo">A new populated photo.</param>
        /// <param name="galleryPhoto">The gallery photo.</param>
        /// <param name="adminPhotos">Photos to be used in admin section</param>
        /// <returns>Insert Count</returns>
        public int Insert(Photo photo, GalleryPhoto galleryPhoto, GalleryPhoto adminPhotos)
        {
            SqlParameter[] parameters =
            {
                    _database.MakeParameter("@Title",SqlDbType.NVarChar,100,photo.Title),
                    _database.MakeParameter("@GalleryId",SqlDbType.Int,4,photo.GalleryId),
                    _database.MakeParameter("@Description",SqlDbType.NVarChar,255,photo.Description),
                    _database.MakeParameter("@DateTaken",SqlDbType.DateTime,8,photo.DateTaken),
                    _database.MakeParameter("@OriginalImage",SqlDbType.Image, galleryPhoto.OriginalImage.Length, galleryPhoto.OriginalImage),
                    _database.MakeParameter("@DisplayImage",SqlDbType.Image, galleryPhoto.DisplayImage.Length, galleryPhoto.DisplayImage),
                    _database.MakeParameter("@ThumbnailImage",SqlDbType.Image, galleryPhoto.ThumbnailImage.Length, galleryPhoto.ThumbnailImage),
                    _database.MakeParameter("@AdminThumbnail",SqlDbType.Image, adminPhotos.ThumbnailImage.Length, adminPhotos.ThumbnailImage),
                    _database.MakeParameter("@AdminFullsizeImage",SqlDbType.Image, adminPhotos.DisplayImage.Length, adminPhotos.DisplayImage),
                    _database.MakeParameter("@Profile",SqlDbType.NVarChar, 50, photo.Profile)

            };

            try
            {
                _database.NonQuery("Photo_Insert", parameters);
            }
            catch (Exception)
            {

                throw;
            }

            return 1;
        }
示例#7
0
 /// <summary>
 /// Inserts Photo into the Photos Table
 /// </summary>
 /// <param name="photo">A new populated photo.</param>
 /// <param name="galleryPhoto"></param>
 /// <param name="adminPhotos">Photos to be used in admin section</param>
 /// <returns>Insert Count</returns>
 public int Insert(Photo photo, GalleryPhoto galleryPhoto, GalleryPhoto adminPhotos)
 {
     return photoDb.Insert(photo, galleryPhoto, adminPhotos, "Photo_Insert");
 }
示例#8
0
 /// <summary>
 /// update gallery images
 /// </summary>
 /// <param name="photoID">id of the photo entry</param>
 /// <param name="photos">new versions of the images</param>
 /// <returns></returns>
 public int UpdateImages(int photoID, GalleryPhoto photos)
 {
     int updateCount = photoDb.UpdateImages(photoID, photos, "Photo_ImagesUpdate");
     return updateCount;
 }