Exemple #1
0
        public async Task OnPost()
        {
            try
            {
                var voterId = TempData.Peek("VoterId");
                if (voterId == null)
                {
                    voterId             = Guid.NewGuid();
                    TempData["VoterId"] = voterId;
                }

                var data = JsonSerializer.Serialize(new { voterId = voterId, vote = Vote });

                _logger.LogInformation($"pushing {data}");

                var plainTextBytes = Encoding.UTF8.GetBytes(data);

                QueueClient queueClient = new QueueClient(Configuration.GetConnectionString("azure-storage"), "test-queue");
                queueClient.CreateIfNotExists();
                await queueClient.SendMessageAsync(Convert.ToBase64String(plainTextBytes));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error submitting vote.");
            }
        }
Exemple #2
0
        public bool CreateQueue()
        {
            try
            {
                // Get the connection string from app settings
                string connectionString = _appConfiguration.Value.StorageConnectionString;

                // Instantiate a QueueClient which will be used to create and manipulate the queue
                _queueClient = new QueueClient(connectionString, _queueName);

                // Create the queue
                _queueClient.CreateIfNotExists();

                if (_queueClient.Exists())
                {
                    Console.WriteLine($"Queue created: '{_queueClient.Name}'");
                    return(true);
                }
                else
                {
                    Console.WriteLine($"Make sure the Azure storage emulator is running and try again.");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Exception: {ex.Message}\n\n");
                Console.WriteLine($"Make sure the Azure storage emulator is running and try again.");
                return(false);
            }
        }
Exemple #3
0
        //-------------------------------------------------
        // Create a message queue
        //-------------------------------------------------
        public bool CreateQueue()
        {
            try
            {
                // <snippet_CreateQueue>
                // Get the connection string from app settings
                string connectionString = ConfigurationManager.AppSettings["storageConnectionString"];

                // Instantiate a QueueClient which will be used to create and manipulate the queue
                QueueClient queueClient = new QueueClient(connectionString, "myqueue");

                // Create the queue
                queueClient.CreateIfNotExists();
                // </snippet_CreateQueue>

                if (queueClient.Exists())
                {
                    Console.WriteLine($"Queue created: '{queueClient.Name}'");
                    return(true);
                }
                else
                {
                    Console.WriteLine($"Make sure the Azurite storage emulator running and try again.");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Exception: {ex.Message}\n\n");
                Console.WriteLine($"Make sure the Azurite storage emulator running and try again.");
                return(false);
            }
        }
        public override void Configure(IFunctionsHostBuilder builder)
        {
            var keyVaultName  = Environment.GetEnvironmentVariable("KeyVaultName");
            var configService = new ConfigService(keyVaultName);

            configService.LoadConfigurationAsync().Wait();

            var tableStorageAccount = CloudStorageAccount.Parse(configService.TableStorageAccountConnectionString);
            var tableClient         = tableStorageAccount.CreateCloudTableClient();

            var jobOutputStatusTable = tableClient.GetTableReference(configService.JobOutputStatusTableName);

            jobOutputStatusTable.CreateIfNotExists();
            var jobOutputStatusTableStorageService = new TableStorageService(jobOutputStatusTable);

            var provisioningRequestQueue = new QueueClient(configService.StorageAccountConnectionString, configService.ProvisioningRequestQueueName);

            provisioningRequestQueue.CreateIfNotExists();

            var jobOutputStatusStorageService     = new JobOutputStatusStorageService(jobOutputStatusTableStorageService);
            var provisioningRequestStorageService = new ProvisioningRequestStorageService(provisioningRequestQueue);
            var jobOutputStatusService            = new JobOutputStatusService(jobOutputStatusStorageService, provisioningRequestStorageService);
            var eventGridService = new EventGridService();

            builder.Services.AddSingleton <IJobOutputStatusService>(jobOutputStatusService);
            builder.Services.AddSingleton <IEventGridService>(eventGridService);
        }
        public bool CreateQueue(string queueName)
        {
            try
            {
                QueueClient queueClient = CreateQueueClient(queueName);

                queueClient.CreateIfNotExists();

                if (queueClient.Exists())
                {
                    Console.WriteLine($"Queue created: '{queueClient.Name}'");
                    return(true);
                }
                else
                {
                    Console.WriteLine($"Client not created!");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Exception: {ex.Message}");
                return(false);
            }
        }
        public ConfirmationEmailQueueService(IConfiguration configuration)
        {
            _configuration = configuration;

            _queueClient = new QueueClient(_configuration.GetValue <string>("AzureStorage"), StorageQueues.CONFIRMATION_EMAIL);
            _queueClient.CreateIfNotExists();
        }
Exemple #7
0
        public ForgotPasswordEmailQueueService(IConfiguration configuration)
        {
            _configuration = configuration;

            _queueClient = new QueueClient(_configuration.GetValue <string>("AzureStorage"), StorageQueues.FORGOT_PASSWORD_EMAIL);
            _queueClient.CreateIfNotExists();
        }
Exemple #8
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "SupervisorApi", Version = "v1"
                });
            });
            services.AddSingleton <IRepositoryService>(provider =>
            {
                var connectionString = Configuration["StorageConnectionString"];
                var queueClient      = new QueueClient(connectionString, Names.QueueName);

                // Create the queue
                queueClient.CreateIfNotExists();

                var tableClient = new TableClient(connectionString, Names.TableName);

                // Create the table
                tableClient.CreateIfNotExists();
                var repositoryService = new RepositoryService(queueClient, tableClient);
                return(repositoryService);
            });
        }
        static void Main(string[] args)
        {
            var queueClient = new QueueClient(_storageConnectionString, _storageQueueName);

            queueClient.CreateIfNotExists();

            var count     = 0;
            var stopWatch = new Stopwatch();

            stopWatch.Start();

            do
            {
                QueueMessage[] retrievedMessage = queueClient.ReceiveMessages();

                count += retrievedMessage.Length;

                Task.WhenAll(
                    retrievedMessage.Select(msg => queueClient.DeleteMessageAsync(msg.MessageId, msg.PopReceipt)));

                if (count % 100 == 0)
                {
                    var totalEvents     = count * _batchSize;
                    var timeElapsed     = stopWatch.Elapsed.TotalSeconds;
                    var eventsPerSecond = totalEvents / timeElapsed;
                    Console.WriteLine($"Received {count} messages, {count * _batchSize} events total in {timeElapsed} seconds, {eventsPerSecond} events total/second");
                }
            } while (true);
        }
 public void Create()
 {
     lock (_lock)
     {
         _queueClient.CreateIfNotExists();
     }
 }
        public IActionResult RgbScreenPost()
        {
            string jsonString = string.Empty;

            using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
            {
                jsonString = reader.ReadToEndAsync().Result;
            }

            // Get the connection string from app settings
            string connectionString = Environment.GetEnvironmentVariable("AZURE_QUEUE_CONNECTION_STRING");

            // Instantiate a QueueClient which will be used to create and manipulate the queue
            QueueClient queueClient = new QueueClient(connectionString, "rgbscreenqueue");

            // Create the queue if it doesn't already exist
            queueClient.CreateIfNotExists();

            if (queueClient.Exists())
            {
                // Send a message to the queue
                queueClient.SendMessage(jsonString);
            }

            Console.WriteLine($"Inserted: {jsonString}");

            return(new OkResult());
        }
        public IActionResult DequeueMessage(string key)
        {
            string storedKey = Environment.GetEnvironmentVariable(Environment.GetEnvironmentVariable("STORED_KEY"));

            if (key == storedKey)
            {
                // Get the connection string from app settings
                string connectionString = Environment.GetEnvironmentVariable("AZURE_QUEUE_CONNECTION_STRING");

                // Instantiate a QueueClient which will be used to create and manipulate the queue
                QueueClient queueClient = new QueueClient(connectionString, "rgbscreenqueue");

                // Create the queue if it doesn't already exist
                queueClient.CreateIfNotExists();

                if (queueClient.Exists())
                {
                    // Send a message to the queue
                    Response <QueueMessage> response = queueClient.ReceiveMessage();


                    return(Json(JsonConvert.SerializeObject(response.GetRawResponse())));
                }
            }

            return(Json(new object()));
        }
        public void GetLogAnalyticsSavedSearchTest()
        {
            var config            = InitConfiguration();
            var test              = config.GetSection("SuperQueue");
            var name              = test["Myname"];
            var regionDefinitions = config.GetSection("SuperQueue:QueueClients").Get <List <RegionDefinition> >();
            var goodHam           = regionDefinitions.FirstOrDefault();
            //var terminalSections = this.Configuration.GetSection("Terminals").GetChildren();
            //foreach (var item in terminalSections)
            //{
            //    terminals.Add(new Terminal
            //    {
            //        // perform type mapping here
            //    });
            //}

            SuperQueue mySuperQueue = new SuperQueue(regionDefinitions);



            var         connectionString = GetConnectionString();
            QueueClient queue            = new QueueClient(connectionString, "mystoragequeue");


            queue.CreateIfNotExists();
            queue.SendMessage("myCoolMessage");
            Assert.IsNotNull(queue);
        }
        public static async void ProcessCallbackItem(Model.CallbackItem cbItem)
        {
            var config = GetConfig();
            var client = await GetHttpClient(config);

            var response = await client.GetStringAsync(cbItem.contentUri);

            Model.AuditItem[] auditItems = JsonSerializer.Deserialize <Model.AuditItem[]>(response);
            var sitesToCapture           = getSitesToCapture();
            var siteDictionary           = new Dictionary <string, string>();

            foreach (var siteToCapture in sitesToCapture)
            {
                siteDictionary.Add(siteToCapture.SiteId, siteToCapture.EventsToCapture);
            }
            QueueClient queueClient = new QueueClient(config["StorageAccountConnectionString"], config["AuditQueueName"]);

            // Create the queue if it doesn't already exist
            queueClient.CreateIfNotExists();

            foreach (Model.AuditItem auditItem in auditItems)
            {
                if (auditItem.Site != null && siteDictionary.ContainsKey(auditItem.Site) && (siteDictionary[auditItem.Site].Contains(auditItem.Operation) || siteDictionary[auditItem.Site] == "*"))
                {
                    if (queueClient.Exists())
                    {
                        queueClient.SendMessage(Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes((string)JsonSerializer.Serialize(auditItem))));
                    }
                }
            }
        }
        /// <summary>
        /// Create an instance of this Data Provider.
        /// </summary>
        /// <param name="connectionString">Azure Storage Account connection string.</param>
        /// <param name="queueName">Azure Storage Queue name.</param>
        /// <exception cref="ArgumentNullException">A parameter is null or empty.</exception>
        /// <exception cref="QueueException">Error creating the Azure Storage Queue.</exception>
        public AzureQueueDataProvider(string connectionString, string queueName)
        {
            if (string.IsNullOrWhiteSpace(connectionString))
            {
                throw new ArgumentNullException(nameof(connectionString));
            }

            if (string.IsNullOrWhiteSpace(queueName))
            {
                throw new ArgumentNullException(nameof(queueName));
            }

            // Create the queue client.
            _queueClient = new QueueClient(connectionString, queueName);

            try
            {
                // Create the queue if it doesn't already exist.
                _queueClient.CreateIfNotExists();
            }
            catch (RequestFailedException e)
            {
                throw new QueueException($"Error creating Azure Storage Queue {queueName}: {e.Message}.", e);
            }
        }
        public bool CreateQueue(string queueName)
        {
            try
            {
                QueueClient queueClient = new QueueClient(_connectionString, queueName);

                queueClient.CreateIfNotExists();

                if (queueClient.Exists())
                {
                    Console.WriteLine($"Queue created: '{queueClient.Name}'");
                    return(true);
                }
                else
                {
                    Console.WriteLine($"Make sure the Azurite storage emulator running and try again.");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Exception: {ex.Message}\n\n");
                Console.WriteLine($"Make sure the Azurite storage emulator running and try again.");
                return(false);
            }
        }
Exemple #17
0
        /// <summary>
        /// This is where the work of the sourcerer happens
        /// </summary>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        private async Task RunAsync(CancellationToken cancellationToken)
        {
            int messageCount = 0;

            //Ensure the queue exists
            _queueClient.CreateIfNotExists(cancellationToken: cancellationToken);

            //get config info
            string destinationPathRoot = _configuration["DestinationPathRoot"];
            string destinationSAS      = _configuration["DestinationSAS"];

            //what images should we move
            var imagesToMove = _imageContext.Images
                               .Where(x => x.Url.Contains(".amazonaws.com"));

            //iterate over all the images we want to copy, and write them to the queue
            foreach (var image in imagesToMove)
            {
                //Get the first half of the source url adding on the trailing slash
                var imageUriRoot = new Uri(image.Url).GetLeftPart(UriPartial.Authority) + "/";

                //create the message to put in the queue
                //we use the replicatable class to ensure that the message is in the format that
                //AzReplicate is expecting
                var message = new Replicatable
                {
                    //the file we want to copy, including any required SAS signature
                    Source = image.Url,

                    //the place we want the file to go, including any required SAS signature
                    //in this simple case we want to keep the same file structure in the destination account,
                    //so we are just replacing the front half of the URL and adding on the SAS signature for the destination
                    Destination = $"{image.Url.Replace(imageUriRoot, destinationPathRoot)}?{destinationSAS}",

                    //Anything you pass along in the Diag Info will be available on the completer
                    //Here we are passing along the ID of the record in the database so we can update the
                    //URL in the completer.
                    DiagnosticInfo = new Dictionary <string, string>()
                    {
                        { "ImageId", image.ImageId.ToString() }
                    }
                };

                //convert the message to Json and put it in the queue
                var serializedMessage = JsonConvert.SerializeObject(message);
                await _queueClient.SendMessageAsync(serializedMessage, timeToLive : TimeSpan.FromSeconds(-1), cancellationToken : cancellationToken);

                messageCount++;

                //show some progress in the logs
                if ((messageCount % 100) == 0)
                {
                    _logger.LogInformation($"Sample WebAppSourcerer Worker {messageCount} items added to the queue at {DateTimeOffset.UtcNow}");
                }
            }

            //log that we are all done
            _logger.LogInformation($"Sample WebAppSourcerer Worker Done adding items to the queue. Total message count {messageCount} at {DateTimeOffset.UtcNow}");
        }
Exemple #18
0
        internal static QueueClient GetDeadLetterQueueFrom(string storageConnectionString, string queueName)
        {
            QueueClient queue = new QueueClient(storageConnectionString, queueName + "-deadletter".ToLower());

            queue.CreateIfNotExists();

            return(queue);
        }
Exemple #19
0
 public QueueStorage(IOptions <QueueStorageOptions> storageQueueOptions, ILogger <QueueStorage> log, QueueServiceClient serviceClient)
 {
     _log                    = log;
     _queueClient            = serviceClient.GetQueueClient($"{storageQueueOptions.Value.Namespace}-ingestion");
     _transactionQueueClient = serviceClient.GetQueueClient($"{storageQueueOptions.Value.Namespace}-transaction");
     _queueClient.CreateIfNotExists();
     _transactionQueueClient.CreateIfNotExists();
 }
        /// <summary>
        /// Initialize the appender based on the options set
        /// </summary>
        /// <remarks>
        /// <para>
        /// This is part of the <see cref="T:log4net.Core.IOptionHandler"/> delayed object activation scheme.
        /// The <see cref="M:log4net.Appender.BufferingAppenderSkeleton.ActivateOptions"/> method must be called on this object after the configuration properties have been set.
        /// Until <see cref="M:log4net.Appender.BufferingAppenderSkeleton.ActivateOptions"/> is called this object is in an undefined state and must not be used.
        /// </para>
        /// <para>
        /// If any of the configuration properties are modified then <see cref="M:log4net.Appender.BufferingAppenderSkeleton.ActivateOptions"/> must be called again.
        /// </para>
        /// </remarks>
        public override void ActivateOptions()
        {
            base.ActivateOptions();

            _account = new QueueServiceClient(ConnectionString);
            _queue   = _account.GetQueueClient(QueueName.ToLower());
            _queue.CreateIfNotExists();
        }
    public QueueManagement(IConfiguration configuration)
    {
        Configuration = configuration;
        string connectionString = Configuration["StorageAccountConnectionString"];

        queueClient = new QueueClient(connectionString, "product");
        queueClient.CreateIfNotExists();
    }
        static void Main(string[] args)
        {
            string filename;
            string queueName;
            string storageConnectionString;

            if (args.Length != 3)
            {
                Console.WriteLine("[JOSN file] [QueueName] [StorageConnectionString] ");
                Console.ReadLine();
                return;
            }
            filename  = args[0];
            queueName = args[1];
            storageConnectionString = args[2];

            try
            {
                QueueClient queueClient = new QueueClient(storageConnectionString, queueName);

                queueClient.CreateIfNotExists();

                for (int messageCount = 0; messageCount < 24; messageCount++)
                {
                    for (int deviceCounter = 0; deviceCounter < DevicesCount; deviceCounter++)
                    {
                        int fileNameCounter = deviceCounter % DeviceMessagePayloadFileCount;
                        if ((deviceCounter % 100) == 0)
                        {
                            Console.WriteLine();
                        }

                        string fileName = string.Format(filename, fileNameCounter);

                        string payload = File.ReadAllText(fileName);

                        //For exercising the cache more to see what memory consumption is like
                        //payload = payload.Replace("@dev_id@", 1000 + deviceCounter.ToString("000"));
                        payload = payload.Replace("@dev_id@", deviceCounter.ToString("000"));
                        payload = payload.Replace("@time@", DateTime.UtcNow.ToString("s"));

                        queueClient.SendMessage(Convert.ToBase64String(UTF8Encoding.UTF8.GetBytes(payload)));
                        Console.Write(".");
                        Thread.Sleep(1000);
                    }
                    //Thread.Sleep(1000*60*5);
                    Thread.Sleep(10000);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine();
            Console.WriteLine("Press <enter> to exit");
            Console.ReadLine();
        }
Exemple #23
0
        public AzureQueueClient(BusProperties busProperties, QueueClient queueClient)
        {
            _queueClient = queueClient;
            var connectionString = busProperties.ConnectionString ?? throw new ArgumentNullException(nameof(busProperties.ConnectionString));
            var queueName        = busProperties.QueueName ?? throw new ArgumentNullException(nameof(busProperties.QueueName));

            _queueClient = new QueueClient(connectionString, queueName);
            _queueClient.CreateIfNotExists();
        }
        async Task RunWithOptions(Options options)
        {
            Console.WriteLine("I see dead people");
            if (options.TestPlan != null && options.TestRun != null)
            {
                DeleteReportsFromDatabase(testPlan: options.TestPlan, testRun: options.TestRun);
                _appLifetime.StopApplication();
                return;
            }

            try
            {
                bool runOnceAndStop       = false;
                bool alreadyGotTheResults = false;

                while (!commonCancellationToken.IsCancellationRequested && !runOnceAndStop)
                {
                    runOnceAndStop = Environment.GetEnvironmentVariable("RunOnceAndStop") != null?bool.Parse(Environment.GetEnvironmentVariable("RunOnceAndStop")) : false;

                    var sqlConnectionString     = Environment.GetEnvironmentVariable("JtlReportingDatabase");
                    var storageConnectionString = Environment.GetEnvironmentVariable("JtlReportingStorage");
                    logger.LogInformation("Checking for the existence of the JtlPendingReports storage queue.");
                    QueueClient queueClient = new QueueClient(storageConnectionString, "JtlPendingReports".ToLower());
                    queueClient.CreateIfNotExists();
                    if (queueClient.Exists())
                    {
                        logger.LogInformation("The JtlPendingReports queue exists.");
                        logger.LogInformation("Checking to see if there are any messages to process.");
                        if ((queueClient.PeekMessages().Value.Length == 0) && !alreadyGotTheResults)
                        {
                            AddResultsToTheQueue(queueClient, storageConnectionString, sqlConnectionString);
                            alreadyGotTheResults = true;
                        }
                        SendResultsToSql(queueClient: queueClient, storageConnectionString: storageConnectionString, sqlConnectionString: sqlConnectionString);
                    }
                    if (!runOnceAndStop)
                    {
                        logger.LogInformation("Hanging out for 15 seconds.");
                        await Task.Delay(15000, commonCancellationToken);
                    }
                }
                logger.LogInformation("All done by by.");
            }
            catch (Exception ex)
            {
                logger.LogError(ex, "Unhandled exception!");
                throw;
            }
            finally
            {
                // Stop the application once the work is done
                _appLifetime.StopApplication();
            }
        }
Exemple #25
0
        /// <summary>
        /// 添加消息
        /// </summary>
        /// <param name="msg">消息</param>
        /// <returns></returns>
        public async Task AddMessage(string msg)
        {
            // Create the queue
            _queueClient.CreateIfNotExists();

            if (_queueClient.Exists())
            {
                // Send a message to the queue
                await _queueClient.SendMessageAsync(msg.EncryptBase64());
            }
        }
        private void InsertMessage(string queueName, string message, string connectionString)
        {
            QueueClient queueClient = new QueueClient(connectionString, queueName);

            queueClient.CreateIfNotExists();

            if (queueClient.Exists())
            {
                queueClient.SendMessage(message);
            }
        }
Exemple #27
0
        internal static QueueClient GetQueueFrom(string storageConnectionString, string queueName, bool createQueueIfItDoesNotExist)
        {
            QueueClient queue = new QueueClient(storageConnectionString, queueName);

            if (createQueueIfItDoesNotExist)
            {
                queue.CreateIfNotExists();
            }

            return(queue);
        }
        private readonly QueueClient _queueClient;// "ServiceRequestsQueue");
        public AzureStorageQueueClient(IOptions <NotificationQueueSettings> settings)
        {
            var settings1 = settings.Value;

            //var connectionString = "UseDevelopmentStorage=true";

            // Instantiate a QueueClient which will be used to create and manipulate the queue

            _queueClient = new QueueClient(settings1.ConnectionString, AzureStorageNames.EmailInputDataQueue);
            // Create the queue
            _queueClient.CreateIfNotExists();
        }
Exemple #29
0
        public async Task NotifyOnUploadAsync(string message)
        {
            var options = new QueueClientOptions()
            {
                MessageEncoding = QueueMessageEncoding.Base64
            };
            var queueClient = new QueueClient(_configuration[Defines.STORAGE_ACCOUNT_CONNECTION_STRING_SECTTION], _configuration[Defines.QUEUE_NAME_SECTION], options);

            queueClient.CreateIfNotExists();
            var encodedMessage = Convert.ToBase64String(Encoding.UTF8.GetBytes(message));
            await queueClient.SendMessageAsync(encodedMessage);
        }
        public async Task <IActionResult> AddressAndPayment(Order order)
        {
            var formCollection = await HttpContext.Request.ReadFormAsync();

            try
            {
                if (string.Equals(formCollection["PromoCode"].FirstOrDefault(), PromoCode,
                                  StringComparison.OrdinalIgnoreCase) == false)
                {
                    return(View(order));
                }
                else
                {
                    order.Username  = HttpContext.User.Identity.Name;
                    order.OrderDate = DateTime.Now;

                    //Add the Order
                    _db.Orders.Add(order);
                    await _db.SaveChangesAsync(HttpContext.RequestAborted);

                    //Process the order
                    var cart = ShoppingCart.GetCart(_db, HttpContext);
                    cart.CreateOrder(order);

                    // Save all changes
                    await _db.SaveChangesAsync(HttpContext.RequestAborted);

                    try
                    {
                        string      connectionString = Configuration[ConfigurationPath.Combine("ConnectionStrings", "StorageConnectionString")];
                        QueueClient queueClient      = new QueueClient(connectionString, "orders");
                        queueClient.CreateIfNotExists();
                        if (queueClient.Exists())
                        {
                            var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(order.OrderId.ToString());
                            queueClient.SendMessage(System.Convert.ToBase64String(plainTextBytes));
                        }
                    }
                    catch (Exception ex)
                    {
                        return(View("Error"));
                    }

                    return(RedirectToAction("Complete",
                                            new { id = order.OrderId }));
                }
            }
            catch (Exception ex)
            {
                return(View("Error"));
            }
        }