示例#1
0
        public static async Task ReloadData()
        {
            Vendors.Clear();
            Fuelings.Clear();
            Summary.Clear();

            await InitData(silent : true);
        }
示例#2
0
        public static async Task DeleteFueling(Fueling fueling)
        {
            if (fueling == null)
            {
                return;
            }

            Fuelings.Remove(fueling);

            if (!fueling.IsNew)
            {
                await AppStorage.Instance.DeleteFueling(fueling);
            }
        }
示例#3
0
        void CreateCells(bool reload)
        {
            if (reload)
            {
                App.Fuelings.CollectionChanged -= Fuelings_CollectionChanged;
                Fuelings.Clear();
            }
            foreach (var fueling in App.Fuelings)
            {
                Fuelings.Add(new FuelingCell(fueling));
            }

            App.Fuelings.CollectionChanged += Fuelings_CollectionChanged;
        }
示例#4
0
 private void Fuelings_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Add)
     {
         foreach (var item in e.NewItems)
         {
             if (item is Fueling fueling)
             {
                 Fuelings.Add(new FuelingCell(fueling));
             }
             else
             {
                 Debug.Print($"Unknown item in Fueligs list: {item.GetType()}");
             }
         }
     }
     else
     {
         CreateCells(true);
     }
 }
示例#5
0
        public static async Task NewFueling(Fueling fueling)
        {
            await AppStorage.Instance.AddFueling(fueling);

            Fuelings.Add(fueling);
        }
示例#6
0
 public static Fueling GetFueling(string id)
 {
     return(Fuelings.FirstOrDefault((fueling) => fueling.Id == id));
 }