Esempio n. 1
0
        /// <summary>
        /// The Count method is used to count the amount of transaction items that have been
        /// added to a specific transaction based on the transaction type (either being rental or sale).
        /// </summary>
        /// <param name="transactionID">The transaction's primary key.</param>
        /// <param name="TransactionType">The transaction type.</param>
        /// <returns>The count of items relating to a transaction & type.</returns>
        public static int Count(int transactionID, TransactionItem.TransactionType type)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@TransactionID", transactionID);
            parameters.Add("@Type", (int)type);
            return(DataSQL <Transaction> .ScalarQuery(SQL_COUNT, parameters));
        }
Esempio n. 2
0
        /// <summary>
        /// The List method is used to fetch all objects within the corresponding database table. It uses
        /// the generic List method of the DataSQL class to fetch the instances. It uses Reflection to dynamically
        /// instantiate the object based on the generic type. It doesn't however return a List of TransactionItem,
        /// instead it will return the DVDCopy objects relating to the Item.
        /// </summary>
        /// <param name="transactionID">The Transaction primary key.</param>
        /// <param name="TransactionType">The Transaction Type.</param>
        /// <returns>Returns a List of the DVD Copies.</returns>
        public static List <DVDCopy> List(int transactionID, TransactionItem.TransactionType type)
        {
            // Instantiates a empty list of DVDCopy.
            List <DVDCopy> list = new List <DVDCopy>();
            // Prepares and adds the paramaters to the dictionary.
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@TransactionID", transactionID);
            parameters.Add("@Type", (int)type);
            // Executes the query through the helper, then iterates the resulting TransactionItems.
            foreach (TransactionItem item in DataSQL <TransactionItem> .List(SQL_LIST, parameters))
            {
                // Adds each item's relating DVDCopy instance to the DVD Copy list.
                list.Add(item.copy);
            }
            return(list); // Returns the List.
        }
Esempio n. 3
0
 public void AddItem(DVDCopy copy, TransactionItem.TransactionType type)
 {
     DataTransactionItem.Add(new TransactionItem(this.transactionID, copy.copyID, type));
 }