private static ItemAttributeOptionDTO Populate(SqlDataReader reader)
        {
            ItemAttributeOptionDTO obj = new ItemAttributeOptionDTO()
            {
                ItemAttributeID       = reader.GetInt32(reader.GetOrdinal("ItemAttributeID")),
                ItemAttributeOptionID = reader.GetInt32(reader.GetOrdinal("ItemAttributeOptionID")),
                DisplayLabel          = reader.GetString(reader.GetOrdinal("DisplayLabel")),
                DisplayOrder          = reader.GetInt32(reader.GetOrdinal("DisplayOrder")),
                Value = reader.GetString(reader.GetOrdinal("Value"))
            };

            return(obj);
        }
        public ItemAttributeOptionDTO UpdateItemAttributeOption(ItemAttributeOptionDTO item)
        {
            using (SqlConnection connection = new SqlConnection(Properties.Settings.Default.DatabaseConnectoin))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand())
                {
                    command.CommandText = "UPDATE [dbo].[ItemAttributeOption] SET [DisplayLabel] = @DisplayLabel, [Value] = @Value, [DisplayOrder] = @DisplayOrder WHERE [ItemAttributeOptionID] = @ItemAttributeOptionID";
                    command.CommandType = CommandType.Text;
                    command.Parameters.AddWithValue("@DisplayLabel", item.DisplayLabel);
                    command.Parameters.AddWithValue("@Value", item.Value);
                    command.Parameters.AddWithValue("@DisplayOrder", item.DisplayOrder);
                    command.Parameters.AddWithValue("@ItemAttributeOptionID", item.ItemAttributeOptionID);
                    command.ExecuteNonQuery();
                }

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

            return(item);
        }
        public ItemAttributeOptionDTO InsertItemAttributeOption(ItemAttributeOptionDTO item)
        {
            using (SqlConnection connection = new SqlConnection(Properties.Settings.Default.DatabaseConnectoin))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand())
                {
                    command.CommandText = "INSERT INTO [dbo].[ItemAttributeOption] ([DisplayLabel], [Value], [DisplayOrder], [ItemAttributeID]) VALUES (@DisplayLabel, @Value, @DisplayOrder, @ItemAttributeID); SELECT @@IDENTITY AS [ID]";
                    command.CommandType = CommandType.Text;
                    command.Parameters.AddWithValue("@DisplayLabel", item.DisplayLabel);
                    command.Parameters.AddWithValue("@Value", item.Value);
                    command.Parameters.AddWithValue("@DisplayOrder", item.DisplayOrder);
                    command.Parameters.AddWithValue("@ItemAttributeID", item.ItemAttributeID);
                    item.ItemAttributeOptionID = Convert.ToInt32(command.ExecuteScalar());
                }

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

            return(item);
        }