public override List <ProductPhoto> GetProductPhotoList()
        {
            List <ProductPhoto> list = new List <ProductPhoto>();

            using (SqlConnection connection = this.GetSqlConnection())
            {
                string     cmdText = "select * from SuCommerce_Photos";
                SqlCommand command = new SqlCommand(cmdText, connection)
                {
                    CommandType = CommandType.Text
                };
                connection.Open();
                using (SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection))
                {
                    ProductPhoto photo = null;
                    while (reader.Read())
                    {
                        photo = new ProductPhoto();
                        CommerceDataProvider.PopulateProductPhotoList(reader, photo);
                        list.Add(photo);
                    }
                    reader.Close();
                    connection.Close();
                }
            }
            return(list);
        }
示例#2
0
        /// <summary>
        /// Insert a photo as product pictures.
        /// </summary>
        /// <remarks>
        /// This method is called directly by UI using ASP.NET ObjectDataSource.
        /// </remarks>
        public static int InsertPhoto(int productID, byte[] bytesFull, byte[] bytesMedium, byte[] bytesSmall, bool useAsPreview)
        {
            int photoId = -1;

            if (bytesFull != null && bytesMedium != null && bytesSmall != null)
            {
                var productPhoto = new ProductPhoto
                {
                    ProductID     = productID,
                    IsMainPreview = useAsPreview
                };

                photoId = AddPhoto(productPhoto);

                string fullSizePath   = ImageHelper.GetFilePath(photoId, false, SueetiePhotoSize.Full, SueetiePhotoType.ProductPhoto);
                string mediumSizePath = ImageHelper.GetFilePath(photoId, false, SueetiePhotoSize.Medium, SueetiePhotoType.ProductPhoto);
                string smallSizePath  = ImageHelper.GetFilePath(photoId, false, SueetiePhotoSize.Small, SueetiePhotoType.ProductPhoto);

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

                CommerceCommon.ClearMarketplaceCache();
            }

            return(photoId);
        }
示例#3
0
        public static int AddPhoto(ProductPhoto productPhoto)
        {
            int num = -1;

            num = CommerceDataProvider.LoadProvider().AddPhoto(productPhoto);
            ClearProductPhotoListCache();
            return(num);
        }
示例#4
0
        public static void SetAdPreviewPhoto(int productID, int photoID)
        {
            CommerceDataProvider provider     = CommerceDataProvider.LoadProvider();
            ProductPhoto         productPhoto = new ProductPhoto
            {
                PhotoID   = photoID,
                ProductID = productID
            };

            provider.SetPreviewPhoto(productPhoto);
            CommerceCommon.ClearMarketplaceCache();
        }
 public override void SetPreviewPhoto(ProductPhoto productPhoto)
 {
     using (SqlConnection connection = this.GetSqlConnection())
     {
         using (SqlCommand command = new SqlCommand("SuCommerce_PreviewPhoto_Set", connection))
         {
             command.CommandType = CommandType.StoredProcedure;
             command.Parameters.Add("@PhotoID", SqlDbType.Int, 4).Value   = productPhoto.PhotoID;
             command.Parameters.Add("@ProductID", SqlDbType.Int, 4).Value = productPhoto.ProductID;
             connection.Open();
             command.ExecuteNonQuery();
             connection.Close();
         }
     }
 }
        public override int AddPhoto(ProductPhoto productPhoto)
        {
            int num = 0;

            using (SqlConnection connection = this.GetSqlConnection())
            {
                using (SqlCommand command = new SqlCommand("SuCommerce_Photo_Add", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add("@ProductID", SqlDbType.Int, 4).Value     = productPhoto.ProductID;
                    command.Parameters.Add("@IsMainPreview", SqlDbType.Bit, 1).Value = productPhoto.IsMainPreview;
                    command.Parameters.Add("@PhotoID", SqlDbType.Int).Direction      = ParameterDirection.Output;
                    connection.Open();
                    command.ExecuteNonQuery();
                    num = (int)command.Parameters["@PhotoId"].Value;
                    connection.Close();
                }
            }

            return(num);
        }
示例#7
0
 public abstract void SetPreviewPhoto(ProductPhoto productPhoto);
示例#8
0
 public abstract int AddPhoto(ProductPhoto productPhoto);