Пример #1
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));
            }
        }
Пример #2
0
        /// <summary>
        /// Get a basketwrapper based on a provided transactionId
        /// </summary>
        /// <param name="dataContextFactory">Data context factory</param>
        /// <param name="transactionId">Id of the transaction to load in the basket</param>
        /// <returns>An instance of a basketwrapper serving the transaction</returns>
        /// <remarks>
        /// At first attempt the a datacontext based on userIdentity is applied.
        /// If userIdentity datacontext does not contain requested transaction, user does not yet
        /// have access to transaction (new user or new vendor). Use datacontext based on
        /// transactionId instead.
        /// </remarks>
        public static BasketWrapper CreateByTransaction(IDataContextFactory dataContextFactory, Guid transactionId)
        {
            var basket            = new BasketWrapper(dataContextFactory.CreateByTransaction(transactionId));
            var transactionLoaded = basket.LoadTransaction(transactionId);

            if (!transactionLoaded)
            {
                throw new Exception();
            }

            return(basket);
        }
Пример #3
0
        /// <summary>
        /// Get a basketwrapper based on a provided transactionId
        /// </summary>
        /// <param name="dataContextFactory">Data context factory</param>
        /// <param name="transactionId">Id of the transaction to load in the basket</param>
        /// <returns>An instance of a basketwrapper serving the transaction</returns>
        /// <remarks>
        /// At first attempt the a datacontext based on userIdentity is applied.
        /// If userIdentity datacontext does not contain requested transaction, user does not yet
        /// have access to transaction (new user or new vendor). Use datacontext based on 
        /// transactionId instead.
        /// </remarks>
        public static BasketWrapper CreateByTransaction(IDataContextFactory dataContextFactory, Guid transactionId)
        {
            var basket = new BasketWrapper(dataContextFactory.CreateByTransaction(transactionId));
            var transactionLoaded = basket.LoadTransaction(transactionId);

            if (!transactionLoaded)
            {
                throw new Exception();
            }

            return basket;
        }