コード例 #1
0
        public ActionResult Details(int Id)
        {
            var order = new Order();
            using (var orderActions = new OrderActions())
            {
                order = orderActions.GetOrder(Id);
            }

            var vm = new ViewModels.DetailsViewModel
            {
                DisplayName = base.DisplayName,
                Order = order
            };

            return View(vm);
        }
コード例 #2
0
        private async Task RunAsync(CancellationToken cancellationToken)
        {
            // Generate a new PDF-based receipt, save it to Azure Blob storage, and update
            // the customer's order record with the path to the PDF.
            while (!cancellationToken.IsCancellationRequested)
            {
                Trace.TraceInformation("Checking Order Status");

                // Grab order id from the Azure Queue.
                var azureStorageMethods = new AzureStorageMethods();
                int orderId = await azureStorageMethods.GetOrderIdFromQueue();

                if (orderId > 0)
                {
                    // We have received a new Order Id in the queue, requesting a generated Pdf receipt.
                    var order = new Order();
                    using (var orderActions = new OrderActions())
                    {
                        order = orderActions.GetOrder(orderId);

                        if (order != null && order.OrderId > 0)
                        {
                            var orderVm = DataMethods.MapOrderToViewModel(order);

                            var fileName = string.Format("ContosoSportsLeague-Store-Receipt-{0}.pdf", order.OrderId);
                            var receipt = new GenerateReceiptPDF().CreatePdfReport(orderVm, fileName);
                            Trace.TraceInformation("PDF generated. Saving to blob storage...");
                            var receiptUri = azureStorageMethods.UploadPdfToBlob(receipt, fileName);

                            // Update the generated receipt Uri on the order:
                            orderActions.UpdateReceiptUri(order.OrderId, receiptUri);
                        }
                        else
                        {
                            // We couldn't find the order for the passed in Order Id. We should log this somewhere.
                            Trace.TraceError("Could not find the order record based off of the passed in Id: " + orderId.ToString() + ". Receipt PDF not generated.");
                        }
                    }
                }
                Trace.TraceInformation("Pausing for 5 seconds before next check.");
                System.Threading.Thread.Sleep(5000);
            }
        }
コード例 #3
0
        public ActionResult Index()
        {
            //var orderId = 2;
            //var order = new Order();
            List<Order> orders = new List<Order>();
            using (var orderActions = new OrderActions())
            {
                //order = orderActions.GetOrder(orderId);
                orders = orderActions.GetCompletedOrders();
            }

            var vm = new ViewModels.HomeViewModel
            {
                DisplayName = base.DisplayName,
                Orders = orders
            };

            if (Request.IsAuthenticated)
            {
                var user = User.Identity.Name;
            }

            return View(vm);
        }