/// <summary>
 /// Adds the item.
 /// </summary>
 /// <param name="theCategory">The category.</param>
 /// <param name="theStyle">The style.</param>
 /// <param name="name">The name.</param>
 /// <param name="description">The description.</param>
 /// <param name="price">The price.</param>
 /// <param name="quantity">The quantity.</param>
 /// <param name="lateFee">The late fee.</param>
 public void AddItem(Category theCategory, Style theStyle, string name, string description, decimal price,
     uint quantity, decimal lateFee)
 {
     var tempFurniture = new Furniture
     {
         Name = name,
         Description = description,
         Price = price,
         Quantity = quantity,
         CategoryId = theCategory.Id,
         StyleId = theStyle.Id,
         LateFee = lateFee
     };
     this.theRepository.AddOne(tempFurniture);
 }
        /// <summary>
        /// Adds one item to the database.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">@Item is null</exception>
        public string AddOne(Furniture item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(@"Item is null");
            }

            string id = string.Empty;

            const string statement =
                "INSERT INTO Furniture (quantity, name, description, price, lateFee, Category_id, Style_id)" +
                " VALUES (@quantity, @name, @description, @price, @late, @cat, @style)";

            var connection = new MySqlConnection(this.CONNECTION_STRING);

            using (var command = new MySqlCommand(statement))
            {
                command.Parameters.AddWithValue("@quantity", item.Quantity);
                command.Parameters.AddWithValue("@name", item.Name);
                command.Parameters.AddWithValue("@description", item.Description);
                command.Parameters.AddWithValue("@price", item.Price);
                command.Parameters.AddWithValue("@late", item.LateFee);
                command.Parameters.AddWithValue("@cat", item.CategoryId);
                command.Parameters.AddWithValue("@style", item.StyleId);


                command.Connection = connection;

                try
                {
                    command.Connection.Open();
                    command.ExecuteNonQuery();
                    id = command.LastInsertedId.ToString();
                }
                finally
                {
                    command.Connection.Close();
                }
            }

            return id;
        }
        private void furnitureLoader(MySqlDataReader reader, List<Furniture> furnitures)
        {
            while (reader.Read())
            {
                var furniture = new Furniture();
                furniture.Id = ((int)reader["id"]).ToString();
                furniture.Quantity = reader["quantity"] as uint? ?? uint.MinValue;
                furniture.Name = reader["name"] == DBNull.Value ? string.Empty : (string)reader["name"];
                furniture.Description = reader["description"] == DBNull.Value
                    ? string.Empty
                    : (string)reader["description"];
                furniture.Price = reader["price"] as decimal? ?? decimal.Zero;
                furniture.LateFee = reader["lateFee"] as decimal? ?? decimal.Zero;
                furniture.CategoryId = (reader["Category_id"] as int? ?? int.MinValue).ToString();
                furniture.StyleId = (reader["Style_id"] as int? ?? int.MinValue).ToString();
                furniture.CategoryName = reader["CategoryName"] == DBNull.Value ? string.Empty : reader["CategoryName"].ToString();
                furniture.StyleName = reader["StyleName"] == DBNull.Value ? string.Empty : reader["StyleName"].ToString();

                furnitures.Add(furniture);
            }
        }
        /// <summary>
        /// Updates the item by identifier.
        /// </summary>
        /// <param name="item">The item.</param>
        public void UpdateById(Furniture item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(@"Item is null");
            }

            const string statement =
                "UPDATE Furniture " +
                "SET quantity = @quantity, name = @name, description = @description, price = @price, lateFee = @late, Category_id = @cat, Style_id = @style" +
                " WHERE id = @id";

            var connection = new MySqlConnection(this.CONNECTION_STRING);

            using (var command = new MySqlCommand(statement))
            {
                command.Parameters.AddWithValue("@quantity", item.Quantity);
                command.Parameters.AddWithValue("@name", item.Name);
                command.Parameters.AddWithValue("@description", item.Description);
                command.Parameters.AddWithValue("@price", item.Price);
                command.Parameters.AddWithValue("@late", item.LateFee);
                command.Parameters.AddWithValue("@cat", item.CategoryId);
                command.Parameters.AddWithValue("@style", item.StyleId);
                command.Parameters.AddWithValue("@id", item.Id);


                command.Connection = connection;

                try
                {
                    command.Connection.Open();
                    command.ExecuteNonQuery();
                }
                finally
                {
                    command.Connection.Close();
                }
            }
        }
 /// <summary>
 /// Deletes the specified item from the database.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <exception cref="NotImplementedException"></exception>
 public void Delete(Furniture item)
 {
     throw new NotImplementedException();
 }