Beispiel #1
0
        private static CollectionImageDTO Populate(SqlDataReader reader)
        {
            CollectionImageDTO obj = new CollectionImageDTO()
            {
                CollectionID      = reader.GetInt32(reader.GetOrdinal("CollectionID")),
                CollectionImageID = reader.GetInt32(reader.GetOrdinal("CollectionImageID")),
                DisplayOrder      = reader.GetInt32(reader.GetOrdinal("DisplayOrder")),
                Caption           = reader.GetString(reader.GetOrdinal("Caption")),
                ImagePath         = reader.GetString(reader.GetOrdinal("ImagePath"))
            };

            return(obj);
        }
Beispiel #2
0
        public CollectionImageDTO UpdateCollectionImage(CollectionImageDTO item)
        {
            using (SqlConnection connection = new SqlConnection(Properties.Settings.Default.DatabaseConnectoin))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand())
                {
                    command.CommandText = "UPDATE [dbo].[CollectionImage] SET [Caption] = @Caption, [DisplayOrder] = @DisplayOrder WHERE [CollectionImageID] = @CollectionImageID";
                    command.CommandType = CommandType.Text;
                    command.Parameters.AddWithValue("@Caption", item.Caption);
                    command.Parameters.AddWithValue("@DisplayOrder", item.DisplayOrder);
                    command.Parameters.AddWithValue("@CollectionImageID", item.CollectionImageID);
                    command.ExecuteNonQuery();
                }

                connection.Close();
                connection.Dispose();
            }

            return(item);
        }
Beispiel #3
0
        public CollectionImageDTO InsertCollectionImage(CollectionImageDTO item)
        {
            using (SqlConnection connection = new SqlConnection(Properties.Settings.Default.DatabaseConnectoin))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand())
                {
                    command.CommandText = "INSERT INTO [dbo].[CollectionImage] ([CollectionID], [ImagePath], [Caption], [DisplayOrder]) VALUES (@CollectionID, @ImagePath, @Caption, @DisplayOrder); SELECT @@IDENTITY AS [ID]";
                    command.CommandType = CommandType.Text;
                    command.Parameters.AddWithValue("@CollectionID", item.CollectionID);
                    command.Parameters.AddWithValue("@ImagePath", item.ImagePath);
                    command.Parameters.AddWithValue("@Caption", item.Caption);
                    command.Parameters.AddWithValue("@DisplayOrder", item.DisplayOrder);
                    item.CollectionImageID = Convert.ToInt32(command.ExecuteScalar());
                }

                connection.Close();
                connection.Dispose();
            }

            return(item);
        }