Exemple #1
0
        public TruckRepairViewModel()
        {
            TruckRepair            = new ObservableRangeCollection <Models.TruckRepair>();
            LoadTruckRepairCommand = new Command(() => ExecuteLoadTruckRepairCommand());
            DeleteCommand          = new Command(() => ExecutedeleteCommand());

            MessagingCenter.Subscribe <NewTruckRepairPage, TruckRepair>(this, "AddItem", async(obj, truckrepair) =>
            {
                var _truckrepair     = truckrepair as TruckRepair;
                _truckrepair.TruckID = truck.ID;
                TruckRepair.Add(_truckrepair);
                await TruckRepairStore.AddTruckRepairAsync(_truckrepair);
            });
        }
Exemple #2
0
        async void ExecuteLoadTruckRepairCommand()
        {
            try
            {
                TruckRepair.Clear();
                var truckrepairs = await TruckRepairStore.GetbyTruckRepairAsync(truck);

                TruckRepair.ReplaceRange(truckrepairs);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                MessagingCenter.Send(new MessagingCenterAlert
                {
                    Title   = "Error",
                    Message = "Unable to load Trucks Repairs.",
                    Cancel  = "OK"
                }, "message");
            }
        }
Exemple #3
0
 async void ExecutedeleteCommand()
 {
     await TruckRepairStore.DeleteTruckRepairAsync(truckrepair);
 }