Ejemplo n.º 1
0
        public static ImageFormatModel GetImageFormat(string accountNameKey, string groupType, string groupName, string formatName, out ImageFormatGroupModel imageGroup)
        {
            imageGroup = null;
            ImageFormatModel imageFormat = null;

            //Get all formats for this group type
            var imageFormats = GetImageFormats(accountNameKey, groupType);

            //Extract the correct image format for this processing submission
            foreach (ImageFormatGroupModel group in imageFormats)
            {
                if (group.ImageFormatGroupNameKey == groupName)
                {
                    imageGroup = group;

                    foreach (ImageFormatModel format in group.ImageFormats)
                    {
                        if (format.ImageFormatNameKey == formatName)
                        {
                            imageFormat = format;
                        }
                    }
                }
            }



            return(imageFormat);
        }
Ejemplo n.º 2
0
        public static DataAccessResponseType DeleteImageFormat(Account account, string imageGroupTypeNameKey, string imageGroupNameKey, string imageFormatNameKey)
        {
            var response = new DataAccessResponseType();

            //Get image formats for this grouptype
            var imageFormats = GetImageFormats(account.AccountNameKey, imageGroupTypeNameKey);
            ImageFormatModel imageFormatToDelete = null;

            #region Extract Format from GroupType/Group

            foreach (ImageFormatGroupModel group in imageFormats)
            {
                if (group.ImageFormatGroupNameKey == imageGroupNameKey)
                {
                    foreach (ImageFormatModel format in group.ImageFormats)
                    {
                        if (format.ImageFormatNameKey == imageFormatNameKey)
                        {
                            imageFormatToDelete = format;
                        }
                    }
                }
            }

            #endregion

            #region Validate Process Allowed

            if (imageFormatToDelete == null)
            {
                return(new DataAccessResponseType
                {
                    isSuccess = false,
                    ErrorMessage = "Image format does not exist!"
                });
            }

            //Make sure deletion is allowed
            if (!imageFormatToDelete.AllowDeletion)
            {
                return(new DataAccessResponseType
                {
                    isSuccess = false,
                    ErrorMessage = "Deletion is not allowed on this image format."
                });
            }

            #endregion

            response.isSuccess = Sql.Statements.DeleteStatements.DeleteImageFormat(account.SqlPartition, account.SchemaName, imageFormatToDelete.ImageFormatID.ToString());

            //Clear Cache
            if (response.isSuccess)
            {
                Caching.InvalidateImageFormatCaches(account.AccountNameKey);
            }

            return(response);
        }
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        private void Initialize()
        {
            _imageFormatCollection.Clear();
            int index = 0;

            foreach (string format in _imgFormats)
            {
                var model = new ImageFormatModel(format, $".{format.ToLower(CultureInfo.CurrentCulture)}", index++);
                _imageFormatCollection.Add(model);
            }
        }
Ejemplo n.º 4
0
            public static ImageRecordModel ImageFormat_To_ImageRecord(ImageFormatModel imageFormat)
            {
                var imageRecord = new ImageRecordModel();

                if (!imageFormat.Gallery)
                {
                    imageRecord.Type = "single";
                }
                else
                {
                    imageRecord.Type = "gallery";
                }

                imageRecord.Height = imageFormat.Height;
                imageRecord.Width  = imageFormat.Width;

                imageRecord.FormatName    = imageFormat.ImageFormatName;
                imageRecord.FormatNameKey = imageFormat.ImageFormatNameKey;

                return(imageRecord);
            }
Ejemplo n.º 5
0
        public static ImageFormatModel DataReader_to_ImageFormatModel(SqlDataReader reader)
        {
            ImageFormatModel imageFormatModel = new ImageFormatModel();

            imageFormatModel.ImageFormatGroupNameKey     = (String)reader["ImageGroupNameKey"];
            imageFormatModel.ImageFormatGroupTypeNameKey = (String)reader["ImageGroupTypeNameKey"];

            imageFormatModel.ImageFormatID      = (Guid)reader["ImageFormatID"];
            imageFormatModel.ImageFormatName    = (String)reader["ImageFormatName"];
            imageFormatModel.ImageFormatNameKey = (String)reader["ImageFormatNameKey"];

            imageFormatModel.Height = (int)reader["Height"];
            imageFormatModel.Width  = (int)reader["Width"];

            imageFormatModel.OrderID = (int)reader["OrderID"];

            imageFormatModel.Listing       = (bool)reader["Listing"];
            imageFormatModel.Gallery       = (bool)reader["Gallery"];
            imageFormatModel.Visible       = (bool)reader["Visible"];
            imageFormatModel.AllowDeletion = (bool)reader["AllowDeletion"];

            return(imageFormatModel);
        }
Ejemplo n.º 6
0
        internal static DataAccessResponseType InsertImageFormat(string sqlPartition, string schemaId, ImageFormatModel imageFormat)//, int maxAllowed) //<-- Removed, now checked above AFTER removing non custom types
        {
            DataAccessResponseType response = new DataAccessResponseType();

            StringBuilder SqlStatement = new StringBuilder();


            //newAccountModel.Provisioned = false;

            //SQL Statements =============================================================

            //Check Row Count ===========================================================
            //SqlStatement.Append("DECLARE @ObjectCount INT ");

            /*SqlStatement.Append("SET @ObjectCount = (SELECT COUNT(*) ");
             * SqlStatement.Append("FROM ");
             * SqlStatement.Append(schemaId);
             * SqlStatement.Append(".ImageFormat) ");
             * SqlStatement.Append("IF @ObjectCount < '");
             * SqlStatement.Append(maxAllowed);
             * SqlStatement.Append("' ");
             * SqlStatement.Append("BEGIN ");*/

            //INSERT =============================================================
            SqlStatement.Append("INSERT INTO  ");
            SqlStatement.Append(schemaId);
            SqlStatement.Append(".ImageFormat (");

            SqlStatement.Append("ImageGroupTypeNameKey,");
            SqlStatement.Append("ImageGroupNameKey, ");
            SqlStatement.Append("ImageFormatID,");
            SqlStatement.Append("ImageFormatName,");
            SqlStatement.Append("ImageFormatNameKey,");
            SqlStatement.Append("Height,");
            SqlStatement.Append("Width,");
            SqlStatement.Append("Gallery,");
            SqlStatement.Append("Listing,");
            SqlStatement.Append("CreatedDate");

            SqlStatement.Append(") VALUES (");

            //Using parameterized queries to protect against injection
            SqlStatement.Append("@ImageGroupTypeNameKey, ");
            SqlStatement.Append("@ImageGroupNameKey, ");
            SqlStatement.Append("@ImageFormatID, ");
            SqlStatement.Append("@ImageFormatName, ");
            SqlStatement.Append("@ImageFormatNameKey, ");
            SqlStatement.Append("@Height, ");
            SqlStatement.Append("@Width, ");
            SqlStatement.Append("@Gallery, ");
            SqlStatement.Append("@Listing, ");
            SqlStatement.Append("@CreatedDate");

            SqlStatement.Append(")");

            //CLOSE: Check Row Count ===========================================================
            //SqlStatement.Append(" END");

            //SqlCommand sqlCommand = new SqlCommand(SqlStatement.ToString(), Sahara.Core.Settings.Azure.Databases.DatabaseConnections.DatabasePartitionSqlConnection(sqlPartition));
            SqlCommand sqlCommand = Sahara.Core.Settings.Azure.Databases.DatabaseConnections.DatabasePartitionSqlConnection(sqlPartition).CreateCommand();

            sqlCommand.CommandText = SqlStatement.ToString();



            //Using parameterized queries to protect against injection
            sqlCommand.Parameters.Add("@ImageGroupTypeNameKey", SqlDbType.Text);
            sqlCommand.Parameters.Add("@ImageGroupNameKey", SqlDbType.Text);
            sqlCommand.Parameters.Add("@ImageFormatID", SqlDbType.UniqueIdentifier);
            sqlCommand.Parameters.Add("@ImageFormatName", SqlDbType.Text);
            sqlCommand.Parameters.Add("@ImageFormatNameKey", SqlDbType.Text);
            sqlCommand.Parameters.Add("@Height", SqlDbType.Int);
            sqlCommand.Parameters.Add("@Width", SqlDbType.Int);
            sqlCommand.Parameters.Add("@Gallery", SqlDbType.Bit);
            sqlCommand.Parameters.Add("@Listing", SqlDbType.Bit);
            sqlCommand.Parameters.Add("@CreatedDate", SqlDbType.DateTime);

            //Assign values
            sqlCommand.Parameters["@ImageGroupTypeNameKey"].Value = imageFormat.ImageFormatGroupTypeNameKey;
            sqlCommand.Parameters["@ImageGroupNameKey"].Value     = imageFormat.ImageFormatGroupNameKey;
            sqlCommand.Parameters["@ImageFormatID"].Value         = imageFormat.ImageFormatID;
            sqlCommand.Parameters["@ImageFormatName"].Value       = imageFormat.ImageFormatName;
            sqlCommand.Parameters["@ImageFormatNameKey"].Value    = imageFormat.ImageFormatNameKey;
            sqlCommand.Parameters["@Height"].Value      = imageFormat.Height;
            sqlCommand.Parameters["@Width"].Value       = imageFormat.Width;
            sqlCommand.Parameters["@Gallery"].Value     = imageFormat.Gallery;
            sqlCommand.Parameters["@Listing"].Value     = imageFormat.Listing;
            sqlCommand.Parameters["@CreatedDate"].Value = DateTime.UtcNow;


            // Add output parameters
            //SqlParameter objectCount = sqlCommand.Parameters.Add("@ObjectCount", SqlDbType.Int);
            //objectCount.Direction = ParameterDirection.Output;

            int insertResult = 0;

            sqlCommand.Connection.OpenWithRetry();

            try
            {
                insertResult = sqlCommand.ExecuteNonQueryWithRetry(); // returns Int indicating number of rows affected
                if (insertResult > 0)
                {
                    response.isSuccess = true;
                }
                else
                {
                    /*
                     * if ((int)objectCount.Value >= maxAllowed)
                     * {
                     *  return new DataAccessResponseType
                     *  {
                     *      isSuccess = false,
                     *      ErrorMessage = "Your plan does not allow for more than " + maxAllowed + " image formats. Please upgrade to increase your limits."
                     *      //ErrorMessage = "You have reached the maximum amount of categories for your account. Please upgrade your plan or contact support to increase your limits."
                     *  };
                     * }*/
                }
            }
            catch (Exception e)
            {
                //Log exception and email platform admins
                PlatformExceptionsHelper.LogExceptionAndAlertAdmins(
                    e,
                    "attempting to insert an image format into SQL",
                    System.Reflection.MethodBase.GetCurrentMethod()
                    );

                response.isSuccess    = false;
                response.ErrorMessage = e.Message;
                return(response);
            }

            sqlCommand.Connection.Close();

            return(response);
        }
Ejemplo n.º 7
0
        public static DataAccessResponseType  CreateImageFormat(Account account, string imageGroupTypeNameKey, string imageGroupNameKey, string imageFormatName, int width, int height, bool listing, bool gallery)
        {
            var response = new DataAccessResponseType();

            #region Validate Plan Restrictions

            if (GetCustomImageFormatCount(account.AccountNameKey) >= account.PaymentPlan.MaxImageFormats)
            {
                return(new DataAccessResponseType {
                    isSuccess = false, ErrorMessage = "You have reached your account restriction of " + account.PaymentPlan.MaxImageFormats + " custom image formats"
                });
            }

            if (gallery && GetCustomImageGalleryCount(account.AccountNameKey) >= account.PaymentPlan.MaxImageGalleries)
            {
                return(new DataAccessResponseType {
                    isSuccess = false, ErrorMessage = "You have reached your account restriction of " + account.PaymentPlan.MaxImageGalleries + " custom image galleries"
                });
            }

            #endregion

            #region Validate Platform Restrictions

            if (listing)
            {
                if (GetCustomImageFormatsAsListingCount(account.AccountNameKey) >= Settings.Objects.Limitations.MaximumImageFormatsAsListings)
                {
                    return(new DataAccessResponseType {
                        isSuccess = false, ErrorMessage = "You have reached the platform restriction of " + Settings.Objects.Limitations.MaximumImageFormatsAsListings + " listing images per inventory"
                    });
                }
            }

            #endregion

            #region Validate Input

            if (String.IsNullOrEmpty(imageGroupTypeNameKey))
            {
                return(new DataAccessResponseType {
                    isSuccess = false, ErrorMessage = "imageGroupTypeNameKey cannot be empty"
                });
            }

            if (String.IsNullOrEmpty(imageGroupNameKey))
            {
                return(new DataAccessResponseType {
                    isSuccess = false, ErrorMessage = "imageGroupNameKey cannot be empty"
                });
            }

            if (String.IsNullOrEmpty(imageFormatName))
            {
                return(new DataAccessResponseType {
                    isSuccess = false, ErrorMessage = "imageFormatName cannot be empty"
                });
            }

            if (listing && gallery)
            {
                return(new DataAccessResponseType {
                    isSuccess = false, ErrorMessage = "Image format cannot be both a Listing and a Gallery"
                });
            }

            if (height < 1)
            {
                return(new DataAccessResponseType {
                    isSuccess = false, ErrorMessage = "Image height must be taller than 1px"
                });
            }
            if (width < 0)
            {
                return(new DataAccessResponseType {
                    isSuccess = false, ErrorMessage = "Image width must be a positive number"
                });
            }
            //if (width < 1) //<-- 0 now means that this is a VARIABLE WIDTH image
            //{
            //return new DataAccessResponseType { isSuccess = false, ErrorMessage = "Image width must be wider than 1px" };
            //}

            if (height > 4000)
            {
                return(new DataAccessResponseType {
                    isSuccess = false, ErrorMessage = "Image height cannot be taller than 4,000px"
                });
            }
            if (width > 4000)
            {
                return(new DataAccessResponseType {
                    isSuccess = false, ErrorMessage = "Image width cannot be wider than 4,000px"
                });
            }

            #endregion

            #region Validate Image Format Name:

            ValidationResponseType ojectNameValidationResponse = ValidationManager.IsValidImageFormatName(imageFormatName);
            if (!ojectNameValidationResponse.isValid)
            {
                return(new DataAccessResponseType {
                    isSuccess = false, ErrorMessage = ojectNameValidationResponse.validationMessage
                });
            }

            #endregion

            //CREATE NAME KEY
            var imageFormatNameKey = Sahara.Core.Common.Methods.ObjectNames.ConvertToObjectNameKey(imageFormatName);

            #region Validate GroupType Exists

            var imageGroupTypes = GetImageFormatGroupTypes();

            bool typeExists = false;

            foreach (ImageFormatGroupTypeModel type in imageGroupTypes)
            {
                if (type.ImageFormatGroupTypeNameKey == imageGroupTypeNameKey)
                {
                    typeExists = true;
                }
            }

            if (!typeExists)
            {
                return(new DataAccessResponseType {
                    isSuccess = false, ErrorMessage = "Format group type '" + imageGroupTypeNameKey + "' does not exists!"
                });
            }

            #endregion

            var imageFormats = GetImageFormats(account.AccountNameKey, imageGroupTypeNameKey);

            #region Validate Group Exists in this Type

            bool groupExistsInType = false;

            foreach (ImageFormatGroupModel group in imageFormats)
            {
                if (group.ImageFormatGroupTypeNameKey == imageGroupTypeNameKey && group.ImageFormatGroupNameKey == imageGroupNameKey)
                {
                    groupExistsInType = true;
                }
            }

            if (!groupExistsInType)
            {
                return(new DataAccessResponseType {
                    isSuccess = false, ErrorMessage = "Format group '" + imageGroupNameKey + "' does not exists!"
                });
            }

            #endregion

            #region Validate Format name is unique to this group/type combo

            bool nameUniqueInGroup = true;

            foreach (ImageFormatGroupModel group in imageFormats)
            {
                if (group.ImageFormatGroupTypeNameKey == imageGroupTypeNameKey && group.ImageFormatGroupNameKey == imageGroupNameKey)
                {
                    foreach (ImageFormatModel format in group.ImageFormats)
                    {
                        if (format.ImageFormatName == imageFormatName || format.ImageFormatNameKey == imageFormatNameKey)
                        {
                            nameUniqueInGroup = false;
                        }
                    }
                }
            }

            if (!nameUniqueInGroup)
            {
                return(new DataAccessResponseType {
                    isSuccess = false, ErrorMessage = "Format name '" + imageFormatNameKey + "' is not unique to the '" + imageGroupNameKey + "' group!"
                });
            }

            #endregion

            #region Create Model & ID

            var imageFormat = new ImageFormatModel
            {
                ImageFormatGroupTypeNameKey = imageGroupTypeNameKey,
                ImageFormatGroupNameKey     = imageGroupNameKey,

                ImageFormatID      = Guid.NewGuid(),
                ImageFormatName    = imageFormatName,
                ImageFormatNameKey = imageFormatNameKey,

                Height = height,
                Width  = width,

                Listing = listing,
                Gallery = gallery
            };

            #endregion

            //INSERT
            response = Sql.Statements.InsertStatements.InsertImageFormat(account.SqlPartition, account.SchemaName, imageFormat); //, account.PaymentPlan.MaxImageFormats);

            //CLear Cache
            if (response.isSuccess)
            {
                Caching.InvalidateImageFormatCaches(account.AccountNameKey);
            }

            return(response);
        }
Ejemplo n.º 8
0
            public static ImageRecordModel TableEntity_To_ImageRecord(string cdnEndpoint, ImageRecordTableEntity imageRecordTableEntity, ImageFormatModel imageFormat, bool isGallery = false)
            {
                var imageRecord = new ImageRecordModel();


                imageRecord.Height = imageRecordTableEntity.Height;
                imageRecord.Width  = imageRecordTableEntity.Width;

                if (!isGallery)
                {
                    imageRecord.Type = "single";

                    imageRecord.Title       = imageRecordTableEntity.Title;
                    imageRecord.Description = imageRecordTableEntity.Description;

                    imageRecord.BlobPath = imageRecordTableEntity.BlobPath;
                    imageRecord.Url      = cdnEndpoint + imageRecordTableEntity.Url;
                    imageRecord.FileName = imageRecordTableEntity.FileName;
                    imageRecord.FilePath = imageRecordTableEntity.FilePath;

                    imageRecord.BlobPath_sm = imageRecordTableEntity.BlobPath.Replace(".jpg", "_sm.jpg").Replace(".gif", "_sm.gif").Replace(".png", "_sm.png");
                    imageRecord.Url_sm      = cdnEndpoint + imageRecordTableEntity.Url.Replace(".jpg", "_sm.jpg").Replace(".gif", "_sm.gif").Replace(".png", "_sm.png");
                    imageRecord.FileName_sm = imageRecordTableEntity.FileName.Replace(".jpg", "_sm.jpg").Replace(".gif", "_sm.gif").Replace(".png", "_sm.png");
                    imageRecord.FilePath_sm = imageRecordTableEntity.FilePath.Replace(".jpg", "_sm.jpg").Replace(".gif", "_sm.gif").Replace(".png", "_sm.png");

                    imageRecord.BlobPath_xs = imageRecordTableEntity.BlobPath.Replace(".jpg", "_xs.jpg").Replace(".gif", "_xs.gif").Replace(".png", "_xs.png");
                    imageRecord.Url_xs      = cdnEndpoint + imageRecordTableEntity.Url.Replace(".jpg", "_xs.jpg").Replace(".gif", "_xs.gif").Replace(".png", "_xs.png");
                    imageRecord.FileName_xs = imageRecordTableEntity.FileName.Replace(".jpg", "_xs.jpg").Replace(".gif", "_xs.gif").Replace(".png", "_xs.png");
                    imageRecord.FilePath_xs = imageRecordTableEntity.FilePath.Replace(".jpg", "_xs.jpg").Replace(".gif", "_xs.gif").Replace(".png", "_xs.png");
                }
                else
                {
                    imageRecord.Type = "gallery";

                    var blobPaths = imageRecordTableEntity.BlobPath.Split('|').ToList();

                    var titles       = imageRecordTableEntity.Title.Split('|').ToList();
                    var descriptions = imageRecordTableEntity.Description.Split('|').ToList();
                    var urls         = imageRecordTableEntity.Url.Split('|').ToList();
                    var fileNames    = imageRecordTableEntity.FileName.Split('|').ToList();
                    var filePaths    = imageRecordTableEntity.FilePath.Split('|').ToList();

                    if (urls.Count > 0)
                    {
                        imageRecord.GalleryImages = new List <ImageRecordGalleryModel>();

                        for (int i = 0; i < urls.Count; i++)
                        {
                            var imageGalleryRecord = new ImageRecordGalleryModel
                            {
                                Url    = cdnEndpoint + urls[i],
                                Url_sm = cdnEndpoint + urls[i].Replace(".jpg", "_sm.jpg").Replace(".gif", "_sm.gif").Replace(".png", "_sm.png"),
                                Url_xs = cdnEndpoint + urls[i].Replace(".jpg", "_xs.jpg").Replace(".gif", "_xs.gif").Replace(".png", "_xs.png")
                            };

                            try
                            {
                                imageGalleryRecord.Title       = titles[i];
                                imageGalleryRecord.Description = descriptions[i];

                                imageGalleryRecord.BlobPath = blobPaths[i];
                                imageGalleryRecord.FileName = fileNames[i];
                                imageGalleryRecord.FilePath = filePaths[i];

                                imageGalleryRecord.BlobPath_sm = blobPaths[i].Replace(".jpg", "_sm.jpg").Replace(".gif", "_sm.gif").Replace(".png", "_sm.png");
                                imageGalleryRecord.FileName_sm = fileNames[i].Replace(".jpg", "_sm.jpg").Replace(".gif", "_sm.gif").Replace(".png", "_sm.png");
                                imageGalleryRecord.FilePath_sm = filePaths[i].Replace(".jpg", "_sm.jpg").Replace(".gif", "_sm.gif").Replace(".png", "_sm.png");

                                imageGalleryRecord.BlobPath_xs = blobPaths[i].Replace(".jpg", "_xs.jpg").Replace(".gif", "_xs.gif").Replace(".png", "_xs.png");
                                imageGalleryRecord.FileName_xs = fileNames[i].Replace(".jpg", "_xs.jpg").Replace(".gif", "_xs.gif").Replace(".png", "_xs.png");
                                imageGalleryRecord.FilePath_xs = filePaths[i].Replace(".jpg", "_xs.jpg").Replace(".gif", "_xs.gif").Replace(".png", "_xs.png");
                            }
                            catch
                            {
                            }

                            imageRecord.GalleryImages.Add(imageGalleryRecord);
                        }
                    }
                }

                imageRecord.FormatName    = imageFormat.ImageFormatName;
                imageRecord.FormatNameKey = imageFormat.ImageFormatNameKey;

                return(imageRecord);
            }
Ejemplo n.º 9
0
        internal static DataAccessResponseType VerifyCommonImageSpecifications(Bitmap bmpSource, ImageFormatModel imageModel)
        {
            var response = new DataAccessResponseType();

            System.Drawing.Imaging.ImageFormat format;

            #region Verify image formats

            try
            {
                format = bmpSource.RawFormat;
                if (!format.Equals(System.Drawing.Imaging.ImageFormat.Jpeg) &&
                    !format.Equals(System.Drawing.Imaging.ImageFormat.Gif) &&
                    !format.Equals(System.Drawing.Imaging.ImageFormat.Png) &&
                    !format.Equals(System.Drawing.Imaging.ImageFormat.Bmp))
                //&& !format.Equals(System.Drawing.Imaging.ImageFormat.Tiff)) //<-- Tiff will be added in future
                {
                    //File is not a supported image type, return error
                    response.isSuccess    = false;
                    response.ErrorMessage = "Please use a supported image file format.";

                    return(response);
                }
            }
            catch
            {
                //File is not an image, return error
                response.isSuccess    = false;
                response.ErrorMessage = "Not a supported image file. Must be of type Jpeg, Gif, Png or Bmp.";     // or Tiff.";<-- Tiff will be added in future

                return(response);
            }

            #endregion

            #region Verify image minimum dimension settings

            if (imageModel.MinSize != null)
            {
                if (bmpSource.Width < imageModel.MinSize.X && bmpSource.Height < imageModel.MinSize.Y)
                {
                    response.isSuccess    = false;
                    response.ErrorMessage = "Image must be at least " + imageModel.GetMinSize();

                    return(response);
                }
                else if (bmpSource.Width < imageModel.MinSize.X)
                {
                    response.isSuccess    = false;
                    response.ErrorMessage = "Image must be at least " + imageModel.MinSize.X + "pixels wide";

                    return(response);
                }
                else if (bmpSource.Height < imageModel.MinSize.Y)
                {
                    response.isSuccess    = false;
                    response.ErrorMessage = "Image must be at least " + imageModel.MinSize.Y + "pixels tall";

                    return(response);
                }
            }


            #endregion

            #region Verify image maximum dimension settings

            //ToDo: Centralize this
            if (imageModel.MaxSize != null)
            {
                if (bmpSource.Width > imageModel.MaxSize.X && bmpSource.Height > imageModel.MaxSize.Y)
                {
                    response.isSuccess    = false;
                    response.ErrorMessage = "Image must be smaller than " + imageModel.GetMaxSize();

                    return(response);
                }
                else if (bmpSource.Width > imageModel.MaxSize.X)
                {
                    response.isSuccess    = false;
                    response.ErrorMessage = "Image must be less than " + imageModel.MaxSize.X + "pixels wide";

                    return(response);
                }
                else if (bmpSource.Height > imageModel.MaxSize.Y)
                {
                    response.isSuccess    = false;
                    response.ErrorMessage = "Image must be less than " + imageModel.MaxSize.Y + "pixels tall";

                    return(response);
                }
            }

            #endregion

            response.isSuccess = true;
            return(response);
        }