Ejemplo n.º 1
0
        private async void DeleteCalibrations_Clicked(object sender, EventArgs e)
        {
            var deleteConfirmation = await DisplayAlert(AppResources.Delete_calibrations, string.Empty, AppResources.Delete, AppResources.Cancel);

            if (deleteConfirmation)
            {
                var calibrationService = Startup.ServiceProvider.GetService <ICalibrationService>();
                var query = new CalibrationsQuery()
                {
                    CalibrationIds = SelectedCalibrations.Select(calibration => calibration.Id).ToArray()
                };
                var deleted = await calibrationService.DeleteCalibrations(query);

                if (deleted)
                {
                    CrossToastPopUp.Current.ShowToastError($"{SelectedCalibrations.Count} {AppResources.Calibrations.ToLower()} {AppResources.Deleted.ToLower()}");
                    SelectedCalibrations.ForEach(deleted =>
                    {
                        var item = Calibrations.FirstOrDefault(calibration => calibration.Id == deleted.Id);
                        Calibrations.Remove(item);
                    });
                    SelectedCalibrations.Clear();
                }
            }
        }
Ejemplo n.º 2
0
        private void Save()
        {
            CalibrationInfo info = null;

            if (_service.TrySaveCalibration(SaveName, _resultData, out info))
            {
                IsSaved = true;

                var oldInfo = Calibrations.FirstOrDefault(i => i.Id == info.Id);
                if (oldInfo != null)
                {
                    Calibrations.Remove(oldInfo);
                }
                Calibrations.Insert(0, info);
            }
        }