Esempio n. 1
0
        /// <summary>
        /// Report transaction complete
        /// </summary>
        /// <param name="key">Encoded key for the transaction</param>
        /// <returns>Transaction complete view</returns>
        /// <remarks>
        /// Does not use cookie. Cookie is removed before this step so a new transaction can 
        /// be started once the transaction has become pending.
        /// </remarks>
        public ActionResult Complete(string key)
        {
            var transactionId = Common.Utils.SafeConvert.ToGuid(key.DecryptUrl());

            using (var basket = BasketWrapper.CreateByTransaction(dataContextFactory, transactionId))
            {
                basket.ExecuteComplete();

                var viewModel = new TransactionDetailsViewModel(basket.Transaction);

                return View(viewModel);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Details of a single transaction
        /// </summary>
        /// <param name="key">Id of the transaction to show</param>
        /// <returns>Transaction details view</returns>
        public ActionResult Details(string key)
        {
            var decryptedKey = Common.Utils.SafeConvert.ToGuid(key.DecryptUrl());

            using (var context = dataContextFactory.CreateByUser())
            {
                //Eager loading Transaction
                var transactionQuery = (from x in context.Transactions where x.TransactionId == decryptedKey select x)
                    .Include(x => x.IgnoredItems)
                    .Include(x => x.TransactionItems.Select(s => s.Sku))
                    .Include(x => x.TransactionItems.Select(s => s.License))
                    .Include(x => x.TransactionItems.Select(s => s.License.Domains))
                    .Include(x => x.TransactionItems.Select(s => s.License.LicenseCustomerApps));

                if (transactionQuery.FirstOrDefault() == null)
                    throw new EntityNotFoundException("Transaction could not be resolved!");

                var viewModel = new TransactionDetailsViewModel(transactionQuery.FirstOrDefault());

                return View(viewModel);
            }
        }
Esempio n. 3
0
        public ActionResult ClaimLicenses(string key)
        {
            var transactionId = Common.Utils.SafeConvert.ToGuid(key.DecryptUrl());

            using (var context = dataContextFactory.CreateByTransaction(transactionId))
            {
                var transaction = (from x in context.Transactions where x.TransactionId == transactionId select x)
                    .Include(x => x.IgnoredItems)
                    .Include(x => x.TransactionItems.Select(s => s.Sku))
                    .Include(x => x.TransactionItems.Select(s => s.License))
                    .FirstOrDefault();

                if (transaction == null)
                    throw new EntityNotFoundException("Transaction could not be resolved!");

                if (transaction.Status == TransactionStatus.Complete)
                    throw new EntityOperationNotSupportedException("Transaction is already claimed!");

                var viewModel = new TransactionDetailsViewModel(transaction);

                return View(viewModel);
            }
        }