Exemple #1
0
        /// <summary>
        /// Creates a new PurchaseManager object
        /// </summary>
        /// <param name="path">The path to store the purchase-record data</param>
        /// <returns>Returns a new instance of a PurchaseManager object</returns>
        public static PurchaseManager CreateNew(string path)
        {
            PurchaseManager pm = new PurchaseManager()
            {
                PurchaseRecord = PurchaseRecord.Create(path)
            };

            return(pm);
        }
Exemple #2
0
        /// <summary>
        /// Merges the purchaseMangaer with the current purchase manager
        /// </summary>
        /// <param name="purchaseManager"></param>
        public void Merge(PurchaseManager purchaseManager)
        {
            foreach (var r in purchaseManager.GetPurchaseRecords())
            {
                Record tr = Get(r.Key);

                if (tr == null)
                {
                    Add(r);
                }

                else if (r.Purchases.Count > tr.Purchases.Count)
                {
                    for (int i = tr.Purchases.Count; i < r.Purchases.Count; i++)
                    {
                        tr.Purchases.Add(r.Purchases[i]);
                    }
                }
            }
        }