public ActionResult Checkout(string key, TransactionCheckoutViewModel viewModel)
        {
            var transactionId = Common.Utils.SafeConvert.ToGuid(key.DecryptUrl());

            if (ModelState.IsValid)
            {
                using (var context = dataContextFactory.CreateByUser())
                using (var basket = BasketWrapper.CreateByTransaction(dataContextFactory, transactionId))
                {
                    if (basket.Transaction == null)
                        throw new EntityNotFoundException("Transaction SKUs are not accessible to current user!");

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

                    viewModel.ToEntity(basket.Transaction);

                    Customer purchasingCustomer;
                    Customer owningCustomer;

                    if (viewModel.ExistingPurchasingCustomer)
                    {
                        purchasingCustomer = context.Customers.SingleOrDefault(x => x.ObjectId == viewModel.PurchasingCustomerId);

                        if (purchasingCustomer == null)
                            return new HttpStatusCodeResult(HttpStatusCode.InternalServerError);
                    }
                    else
                        purchasingCustomer = viewModel.NewPurchasingCustomer.ToEntity(null);

                    if (viewModel.OwningCustomerIsPurchasingCustomerId)
                    {
                        owningCustomer = purchasingCustomer;
                    }
                    else
                    {
                        if (viewModel.ExistingOwningCustomer)
                        {
                            owningCustomer = context.Customers.SingleOrDefault(x => x.ObjectId == viewModel.OwningCustomerId);

                            if (owningCustomer == null)
                                return new HttpStatusCodeResult(HttpStatusCode.InternalServerError);
                        }
                        else
                            owningCustomer = viewModel.NewOwningCustomer.ToEntity(null);

                    }

                    basket.ExecuteCheckout(purchasingCustomer, owningCustomer);

                    return RedirectToAction("Complete", new { key = basket.Transaction.TransactionId.ToString().EncryptUrl() });
                }
            }
            else
            {
                return View(viewModel);
            }
        }
        /// <summary>
        /// Create a single Transaction checkout
        /// </summary>
        /// <param name="key">Encrypted key of the transaction to claim</param>
        /// <returns>Transaction checkout view</returns>
        public ActionResult Checkout(string key)
        {
            var transactionId = Common.Utils.SafeConvert.ToGuid(key.DecryptUrl());

            using (var context = dataContextFactory.CreateByUser())
            using (var basket = BasketWrapper.CreateByTransaction(dataContextFactory, transactionId))
            {
                if (basket.Transaction == null)
                    throw new EntityNotFoundException("Transaction SKUs are not accessible to current user!");

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

                var owningCustomerQuery = (from x in context.Customers orderby x.Name select x);
                var purchasingCustomerQuery = (from x in context.Customers orderby x.Name select x);
                var countryQuery = (from x in context.Countries orderby x.CountryName select x);

                var viewModel = new TransactionCheckoutViewModel(basket.Transaction,
                    owningCustomerQuery.ToList(), purchasingCustomerQuery.ToList(), countryQuery.ToList());

                return View(viewModel);
            }
        }