private async void ButtonAddProfile_Click(object sender, RoutedEventArgs e) { var dialog = new ProfileDialog(); var dialogResult = await dialog.ShowAsync(); if (dialogResult == ContentDialogResult.Primary) { var profile = dialog.Result; if (profile != null) { var existingElement = ProfileExists(profile); if (existingElement != null) { var yesNoDialog = new YesNoDialog("Profil bereits vorhanden", string.Format("Das Profil mit der Profilnummer '{0:s}', einer Länge von '{1:s}' und der Farbe '{2:s}' ist bereits vorhanden. " + "Soll das vorhandene Profil geändert werden?", profile.ProfileNumber, profile.Length, profile.Surface)); await yesNoDialog.ShowAsync(); if (yesNoDialog.Result == YesNoDialogType.Yes) { existingElement.Count += profile.Count; existingElement.Amount += profile.Amount; await UpdateProfile(existingElement); } return; } if (PlantOrder != null) { profile.PlantOrderId = PlantOrder.Id; } if (FileEntry != null) { profile.Filename = FileEntry.Name; } var profileId = await Proxy.CreateProfile(profile); if (profileId > 0) { profile.ProfileId = profileId; var element = AutoMapperConfiguration.Map(profile); ElementCollection.Add(element); } else { var errorDialog = new InfoDialog("Beim Anlegen des Profil's ist ein Fehler aufgetreten!", "Information", InfoDialogType.Error); await errorDialog.ShowAsync(); } } } }
private async void ShowEditProfile(object sender, RoutedEventArgs e) { PrepareProfileDialog(); var answer = await ProfileDialog.ShowAsync(); if (answer != ContentDialogResult.Primary) { return; } using (var scope = IoC.Container.BeginLifetimeScope()) { SplitView.Visibility = Visibility.Collapsed; ProgressRing.Visibility = Visibility.Visible; var userService = scope.Resolve <IUserService>(); var user = await userService.Update(TextBoxLogin.Text, Constant.Key, TextBoxPassword.Password, Constant.User); SplitView.Visibility = Visibility.Visible; ProgressRing.Visibility = Visibility.Collapsed; } }
private async Task UpdateProfile(ElementModel element) { var dialog = new ProfileDialog(element); var dialogResult = await dialog.ShowAsync(); if (dialogResult == ContentDialogResult.Primary && dialog.Mode == ProfileDialogMode.Edit) { var profile = dialog.Result; var result = await Proxy.UpdateProfileAsync(profile); if (result) { UpdateElement(element, profile); } else { var infoDialog = new InfoDialog("Das Profil konnte nicht geändert werden!"); await infoDialog.ShowAsync(); } } }