private void Init() { PropertyChanged += (s, e) => { // Update IsEditable if (e.PropertyName == nameof(Status)) { OnPropertyChanged(nameof(IsEditable)); } if (e.PropertyName == nameof(Label) || e.PropertyName == nameof(Description) || e.PropertyName == nameof(Type)) { ((Command)SaveBelegCommand).ChangeCanExecute(); } //OnPropertyChanged(nameof(CanSave)); }; SaveBelegCommand = new Command(async() => { Beleg beleg = this.GetBusinessObject(); if (beleg.Thumbnail == null && beleg.Image != null) { beleg.Thumbnail = await BelegService.CreateThumbnail(beleg.Image); } var result = Storage.Database.StoreBeleg(beleg).Result; if (result > 0) { Callback(); } }, () => CanSave); StartCameraCommand = new Command(async() => { var img = await ImageServices.CaptureImage(); Image = ConvertStreamToByteArray(img); }); SelectPictureCommand = new Command(async() => { var img = await ImageServices.SelectImage(); Image = ConvertStreamToByteArray(img); }); AddValidations(); }
public static void UpdateStaticValues() { BelagTypes = BelegService.GetTypeList().Result.ToList(); }
public BelegMasterViewModel(INavigation navigation, Beleg[] belegList) { selectMode = false; SelectBelegeCommand = new Command(() => { selectMode = !selectMode; if (!selectMode) { resetSelectedBelege(); } }); ExportBelegeCommand = new Command(async() => { if (!selectMode) { return; } Beleg[] selectedBelege = getSelectedBelege().ToArray(); await new BelegServiceHelper().ExportBelege(selectedBelege); resetSelectedBelege(); selectMode = false; }); DeleteBelegeCommand = new Command(async() => { if (!selectMode) { return; } Beleg[] selectedBelege = getSelectedBelege().ToArray(); int[] belegNummern = new int[selectedBelege.Length]; for (int ix = 0; ix < selectedBelege.Length; ++ix) { belegNummern[ix] = selectedBelege[ix].Belegnummer.Value; } await BelegService.DeleteBelege(BelegService.USER, belegNummern); await Storage.Database.RemoveBelege(selectedBelege); resetSelectedBelege(); selectMode = false; }); AddNewBelegCommand = new Command(() => { navigation.PushAsync(new DetailPage(null, navigation)); }); Belege = new ObservableCollection <BelegDetailsViewModel>(); // Ladeoperation von Service if (belegList != null) { foreach (Beleg beleg in belegList) { _belege.Add(new BelegDetailsViewModel(beleg)); } } }