예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="orderId"></param>
        /// <param name="returnurl"></param>
        /// <returns></returns>
        public static bool Add(string collectionName, Model.Order.OrderBankInfo order)
        {
            try
            {
                using (Mongo server = new Mongo(connectionString))
                {
                    MongoDatabase db = server.GetDatabase(databaseDefault) as MongoDatabase;

                    MongoCollection <Document> coll = db.GetCollection <Document>(collectionName) as MongoCollection <Document>;
                    server.Connect();

                    Document charge = new Document();
                    charge["userid"]    = order.userid.ToString();
                    charge["orderid"]   = order.orderid;
                    charge["userorder"] = order.userorder;
                    charge["returnurl"] = order.returnurl;
                    charge["attach"]    = order.attach;

                    coll.Insert(charge, true);
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="order"></param>
        /// <returns></returns>
        public void Complete(Model.Order.OrderBankInfo order)
        {
            using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
            {
                dal.Complete(order);

                // Update the inventory to reflect the current inventory after the order submission
                //Inventory inventory = new Inventory();
                //inventory.TakeStock(order.LineItems);

                // Calling Complete commits the transaction.
                // Excluding this call by the end of TransactionScope's scope will rollback the transaction
                ts.Complete();
            }
        }
예제 #3
0
        /// <summary>
        /// Inserts the order and updates the inventory stock within a transaction.
        /// </summary>
        /// <param name="order">All information about the order</param>
        public void Insert(Model.Order.OrderBankInfo order)
        {
            using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
            {
                long id = dal.Insert(order);
                if (id <= 0L)
                {
                    new ApplicationException("Add orders fails");
                }

                // Update the inventory to reflect the current inventory after the order submission
                //Inventory inventory = new Inventory();
                //inventory.TakeStock(order.LineItems);

                // Calling Complete commits the transaction.
                // Excluding this call by the end of TransactionScope's scope will rollback the transaction
                ts.Complete();
            }
        }