/// <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> /// Gets all by category style criteria. /// </summary> /// <param name="category">The category.</param> /// <param name="style">The style.</param> /// <returns></returns> public IList<Furniture> GetAllByCategoryStyleCriteria(Category category, Style style) { var furnitures = new List<Furniture>(); const string query = "SELECT Furniture.*, " + "Category.name AS CategoryName, Style.name AS StyleName " + "FROM Furniture, Category, Style " + "WHERE (Furniture.Category_id LIKE @cat AND Furniture.Style_id LIKE @style) AND Furniture.Category_id = Category.id AND Furniture.Style_id = Style.id"; var connection = new MySqlConnection(this.CONNECTION_STRING); using (var command = new MySqlCommand(query)) { command.Connection = connection; command.Parameters.AddWithValue("@cat", category?.Id ?? "%"); command.Parameters.AddWithValue("@style", style?.Id ?? "%"); try { command.Connection.Open(); var reader = command.ExecuteReader(); this.furnitureLoader(reader, furnitures); } finally { command.Connection.Close(); } return furnitures; } }
/// <summary> /// Gets the items by category style. /// </summary> /// <param name="category">The category.</param> /// <param name="style">The style.</param> /// <returns></returns> public IList<Furniture> GetItemsByCategoryStyle(Category category, Style style) { return this.theRepository.GetAllByCategoryStyleCriteria(category, style); }