private void EditPurchase_Click(object sender, RoutedEventArgs e)
 {
     if (Purchases.SelectedIndex != -1)
     {
         PurchaseSummary p     = Purchases.SelectedItem as PurchaseSummary;
         int             purId = p.Id;
         this.Frame.Navigate(typeof(PurchaseInfoView), purId);
     }
 }
        private List <PurchaseSummary> GetPurchaseSummariesForVehicle(Vehicle veh)
        {
            List <Purchase> rawPurchases;

            using (var db = new DbSchema())
            {
                rawPurchases = db.Purchases.Where(p => p.Vehicle == veh).ToList();
            }
            List <PurchaseSummary> purchList = new List <PurchaseSummary>();

            foreach (var rp in rawPurchases)
            {
                PurchaseSummary newPurch = new PurchaseSummary();
                newPurch.Date    = rp.Date.ToString("yyyy-MM-dd");
                newPurch.Gallons = rp.Gallons.ToString("F3");
                newPurch.Cost    = rp.Cost.ToString("C");
                newPurch.Mpg     = Math.Round(rp.Trip / rp.Gallons, 1).ToString("F1");
                newPurch.Dpg     = Math.Round(rp.Cost / rp.Gallons, 2).ToString("C");
                newPurch.Id      = rp.ID;
                purchList.Add(newPurch);
            }
            return(purchList);
        }