Example #1
0
        private static void WriteReservations(Transaction context, StorageManager storage, Reservation[] data, bool abort)
        {
            bool createTransaction = (null == context);

            if (createTransaction)
            {
                context = new Transaction();
            }

            // write the data
            foreach (var item in data)
            {
                storage.Write(context, item.Id, item);
            }

            // read the data in the same transaction
            ReadReservations(context, storage, data);

            if (createTransaction &&
                !abort)
            {
                storage.Prepare(context);
                storage.Commit(context);
            }
            else if (createTransaction &&
                     abort)
            {
                storage.Abort(context);
            }
        }
Example #2
0
        private static void WriteResources(Transaction context, StorageManager storage, Resource[] data, bool abort)
        {
            bool createTransaction = (null == context);
            if (createTransaction)
            {
                context = new Transaction();
            }

            // write the data
            foreach (var item in data)
            {
                storage.Write(context, item.Id, item);
            }

            // read the data in the same transaction
            ReadResources(context, storage, data);

            if (createTransaction
                && !abort)
            {
                storage.Prepare(context);
                storage.Commit(context);
            }
            else if (createTransaction
                && abort)
            {
                storage.Abort(context);
            }
        }