Пример #1
0
 // Serialize the order details
 private async Task SaveOrder(OrderDetails details)
 {
     StorageFile userdetailsfile = await ApplicationData.Current.LocalFolder.CreateFileAsync("OrderDetails", CreationCollisionOption.ReplaceExisting);
     IRandomAccessStream raStream = await userdetailsfile.OpenAsync(FileAccessMode.ReadWrite);
     using (IOutputStream outStream = raStream.GetOutputStreamAt(0))
     {
         // Serialize the Session State.
         DataContractSerializer serializer = new DataContractSerializer(typeof(OrderDetails));
         serializer.WriteObject(outStream.AsStreamForWrite(), details);
         await outStream.FlushAsync();
     }
 }
Пример #2
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            var paymentResult = e.Parameter as ValueSet;
            OrderPlacedMessage.Text = string.Format("Congratulations! You just purchased {0}", paymentResult["ProductName"] as string);            

            //Save this order
            OrderDetails order = new OrderDetails();
            order.ItemName = paymentResult["ProductName"] as string;

            order.OrderPlacedTime = DateTime.UtcNow;

            order.OrderID = GenerateOrderId();

            order.TrackingNumber = GenerateTrackingNumber();

            await this.SaveOrder(order);
        }