private void dataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { var concurso = (ConcursoViewModel)e.AddedItems.First(); if (concurso.ListoParaAbrir) { if (concurso.Concurso.Status == (int)ConcursoStatusEnum.Abierto || concurso.Concurso.Status == (int)ConcursoStatusEnum.Cerrado) { NavigationService.Navigate <ConcursoAbiertoPage>(new { Concurso = concurso }); } else { MessageDialogService.Create("Este concurso esta listo para ser abierto!!", c => { NavigationService.Navigate <ConcursoAbiertoPage>(new { Concurso = concurso }); }, null); } } else { NavigationService.Navigate <DetalleConcursoPage>(new { ConcursoId = concurso.Concurso.Id }); } }
public MainWindowViewModel( Func <Task> avaloniaOpenFile, Func <Task> avaloniaSaveFile, MessageDialogService messageDialogService, ContentDialogService <CustomContentViewModel> contentDialogService, OpenFileDialogService openFileDialogService, SaveFileDialogService saveFileDialogService, PrintDialogService printDialogService) { _messageDialogService = messageDialogService; _contentDialogService = contentDialogService; _openFileDialogService = openFileDialogService; _saveFileDialogService = saveFileDialogService; _printDialogService = printDialogService; ShowMessageCommand = ReactiveCommand.Create(ShowMessageAsync); ShowCustomContentCommand = ReactiveCommand.Create(ShowCustomContentAsync); OpenFileCommand = ReactiveCommand.Create(OpenFileAsync); SaveFileCommand = ReactiveCommand.Create(SaveFileAsync); PrintCommand = ReactiveCommand.Create(PrintAsync); AvaloniaOpenFileCommand = ReactiveCommand.Create(avaloniaOpenFile); AvaloniaSaveFileCommand = ReactiveCommand.Create(avaloniaSaveFile); }
private void OnDeleteImageExecute(int?id) { int ImageKey = (int)id; ImageWrapper image = ArchiveEntity.Images.Where(x => x.ImageKey == ImageKey).First(); var result = MessageDialogService.ShowOKCancelDialog($"Удалить Изображение {image.ImageTitle}?", $"Удалить Изображение {image.ImageTitle}?"); if (result == MessageDialogResult.OK) { if (image != null) { ArchiveEntity.Images.Remove(image); image.PropertyChanged -= Wrapper_PropertyChanged; var wrapper = Images.Where(x => x.ImageKey == ImageKey).First(); Images.Remove(wrapper); _repository.RemoveImage(ArchiveEntity.ArchiveEntityKey, ImageKey); HasChanges = ArchiveEntity != null && !ArchiveEntity.HasErrors; } } /// Дописать удаление файла !!!!!!!!!!!! // RemoveItemFromEntityCollection(_fileOnDriveDataProvider.RemoveImageFromEntity, ImageKey); }
private async Task LoadDataAsync() { (await new ConcursosRepository().GetAsync()) .Success(concursos => { var oncursosToCheck = concursos.Where(c => (c.Status == (int)ConcursoStatusEnum.Nuevo || c.Status == (int)ConcursoStatusEnum.Cerrado) && c.ConcursoProveedores.Any(p => p.Proveedor.UsuarioId == IdentityServices.Instance.GetUserLogged().Id && p.Status != (int)ProveedorConcursoStatusEnum.Rechazado))?.ToList(); foreach (var item in oncursosToCheck) { var concursoProveedor = item.ConcursoProveedores.First(f => f.Proveedor.UsuarioId == IdentityServices.Instance.GetUserLogged().Id); Concursos.Add(new ConcursoParaOfertar(item, concursoProveedor)); } LoadingService.LoadingStop(); }) .Error(async x => { MessageDialogService.Create("No hay concursos para mostrar", c => { LoadingService.LoadingStop(); }, null); }); }
protected override async void OnDeleteExecute() { if (await _friendRepository.HasMeetingsAsync(Friend.Id)) { await MessageDialogService.ShowInfoDialogAsync($"{Friend.FirstName} {Friend.LastName} can`t be deleted, as this friend is part of at least one meeting."); return; } var result = await MessageDialogService.ShowOkCancelDialogAsync($"Do you really want to delete the friend {Friend.FirstName} {Friend.LastName}", "Question"); if (result == MessageDialogResult.OK) { _friendRepository.Remove(Friend.Model); await _friendRepository.SaveAsync(); RaiseDetailDeletedEvent(Friend.Id); //_eventAggregator.GetEvent<AfterDetailDeletedEvent>().Publish( // new AfterDetailDeletedEventArgs // { // Id = Friend.Id, // ViewModelName = nameof(FriendDetailViewModel) // }); } }
private async void OnDeleteAllImagesExecute() { var result = MessageDialogService.ShowOKCancelDialog("Удаление информации об изображениях.", "Удалять информацию по сем картинкам в даном расположении?"); if (result == MessageDialogResult.OK) { var cnf = new ConfigurationData(); var lg = new Logger(); var fm = new FileManager(cnf, lg); IDataManager dm = new DataManager(cnf, fm, lg, 0); var dmResult = dm.RemoveImagesFromDrive(this.Id); if (dmResult.Success) { var path = Path.Combine(cnf.GetTargetImagePath(), string.Format("drive{0}", Id)); fm.DeleteDirectory(path); } await LoadAsync(Id); await MessageDialogService.ShowInfoDialogAsync("Удаление выполнено!"); //TODO: Удаление из БД //TODO: Удаление в файловой системе } }
private async void BtnAccept_Click(object sender, RoutedEventArgs e) { LoadingService.LoadingStart(); var rol = (await new RolRepository().Get()).Result.FirstOrDefault(x => x.Nombre == "Comprador"); Comprador.Usuario = (new Usuario(Email, new HashService().Hash(Password), rol)); (await new CompradoresServices().Registrar(Comprador)) .Success(s => { MessageDialogService.Create("Comprador Registrado Existosamente", c => { LoadingService.LoadingStop(); NavigationService.NavigatePop <Dashboard>(); }, null); }) .Error(erros => { MessageDialogService.Create("Error al Crear el Comprador", c => { LoadingService.LoadingStop(); }, null); }); }
public override void OnFrameworkInitializationCompleted() { base.OnFrameworkInitializationCompleted(); if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { var mainWindow = new MainWindow(); var messageDialogService = new MessageDialogService(mainWindow); var contentDialogService = new ContentDialogService <CustomContentViewModel>( mainWindow, new CustomContentViewResolver()); var openFileDialogService = new OpenFileDialogService(mainWindow); var saveFileDialogService = new SaveFileDialogService(mainWindow); var printDialogService = new PrintDialogService(mainWindow); mainWindow.DataContext = new MainWindowViewModel( () => AvaloniaOpenFile(mainWindow), () => AvaloniaSaveFile(mainWindow), messageDialogService, contentDialogService, openFileDialogService, saveFileDialogService, printDialogService); desktop.MainWindow = mainWindow; } }
private void ImportAsync(ImportModel model) { ProcessManager.RunMainProcessAsync(mindmapStore, async() => { List <ImportResult> results = null; try { results = await model.Source.ImportAsync(model.Importer); } catch { await MessageDialogService.AlertLocalizedAsync("ImportFailed_Alert"); } if (results?.Count > 0) { foreach (var result in results) { await mindmapStore.AddAsync(result.Name, result.Document); } await mindmapStore.OpenAsync(mindmapStore.AllFiles.FirstOrDefault()); } }).Forget(); }
protected override async void OnSaveExecute() { try { await _dataService.SaveAsync(); } catch (DbUpdateConcurrencyException ex) { var dbValue = ex.Entries.Single().GetDatabaseValues(); if (dbValue == null) { MessageDialogService.ShowInfoDialog("The entity has been deleted by another user"); RaiseDetailDeletedEvent(Id); return; } var result = MessageDialogService.ShowOkCancelDialog("The entity has been changed in the meantime by someone else." + "Click OK to save changes anyway, click Cancel to reload the entity from the database.", "Question"); if (result == MessageDialogResult.OK) { var entry = ex.Entries.Single(); entry.OriginalValues.SetValues(entry.GetDatabaseValues()); await _dataService.SaveAsync(); } else { await ex.Entries.Single().ReloadAsync(); await LoadAsync(Friend.Id); } } HasChanges = _dataService.HasChanges(); Id = Friend.Id; RaiseDetailSavedEvent(Friend.Id, $"{Friend.FirstName} {Friend.LastName}"); }
protected async override void OnDeleteExecute() { var result = await MessageDialogService.ShowOkCancelDialogAsync($"Наистина ли искате да изтриете {Exercise.Name}?", "Въпрос"); if (result == MessageDialogResult.OK) { if (await _exerciseRepository.IsReferencedByExerciseSetup(Exercise.Id)) { result = await MessageDialogService.ShowOkCancelDialogAsync($"Упражнението {Exercise.Name} е част от поне една тренировъчна програма." + $" Ако го изтриете, ще бъде премахнато от всички тренировъчни програми." + $" Натиснете ОК за да го изтриете въпреки това. Натисете Cancel за да отмените изтриването.", "Информация"); if (result == MessageDialogResult.OK) { _exerciseRepository.Remove(Exercise.Model); await _exerciseRepository.SaveAsync(); RaiseDetailDeletedEvent(Exercise.Id); } else { return; } } else { _exerciseRepository.Remove(Exercise.Model); await _exerciseRepository.SaveAsync(); RaiseDetailDeletedEvent(Exercise.Id); } } }
private async void DeleteSelectedItemsAsync() { var messageBox = new MessageDialogService(); var msgResult = messageBox.ShowYesNoDialog("Warning!", "Are you sure you to delete selected item(s)?", MessageDialogResult.No); //if (MessageBox.Show("Are you sure you to delete selected item(s)?","Warning!", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.Yes) == MessageBoxResult.Yes) if (msgResult == MessageDialogResult.Yes) { try { await DeleteEmployeesAsync(); await ListAsync(); } catch (Exception) { _eventAggregator.GetEvent <StatusBarEvent>().Publish("Internal Error while deleing employees"); } //await DeleteEmployeesAsync(); //foreach (var employeeWrapper in EmployeeItems.ToList()) //{ // if (employeeWrapper.IsSelected) // { // if (employeeWrapper != null) // { // string Name = employeeWrapper.FirstName + " " + employeeWrapper.LastName; // employeeWrapper.IsDeleted = true; // _clientService.Delete<Employee>(employeeWrapper.Model/*.Employee*/); // EmployeeItems.Remove(employeeWrapper); // MessageBox.Show(Name + " was deleted"); // } // } //} } }
private async void OnShowStatExecute() { SeriesCollection.Clear(); Labels.Clear(); foreach (var product in Products) { if (product.ProductTypeId == SelectedProductType.Id) { SeriesCollection.Add(new ColumnSeries { Title = product.Name, Values = new ChartValues <int> { product.StockBalance } }); Labels.Add(product.ProductType.Type); } } Product = Products.FirstOrDefault(s => s.ProductTypeId == SelectedProductType.Id); if (Product != null) { SelectedProductMeasure = Product.ProductMeasure; } else { await MessageDialogService.ShowInfoDialogAsync( "Продуктов указанного типа нет на складе"); } }
private async void OnAddToExerciseSetupsExecute() { if (Id <= 0) //if it's newly created { await MessageDialogService.ShowInfoDialogAsync("Натиснете бутона ЗАПАЗИ преди да добавите упражнение"); return; } else { var exerciseToAdd = SelectedFilteredExercise; var position = ExerciseSetups.Count + 1; var wrapper = new ExerciseSetupWrapper(new ExerciseSetup { WorkoutId = Id, Position = position, ExerciseId = exerciseToAdd.Id }); wrapper.PropertyChanged += Wrapper_PropertyChanged; _exerciseSetupRepository.Add(wrapper.Model); ExerciseSetups.Add(wrapper); await _exerciseSetupRepository.SaveAsync(); HasChanges = _exerciseSetupRepository.HasChanges(); await _workoutRepository.SaveAsync(); HasChanges = _workoutRepository.HasChanges(); Id = Workout.Id; RaiseDetailSavedEvent(Workout.Id, Workout.Title); SelectedFilteredExercise = null; } }
private async void OnBuyCarExecute() { if (Car.AskingPrice * 0.8 >= Price) { InvalidPriceVisibility = Visibility.Visible; return; } var result = await MessageDialogService.ShowOkCancelDialogAsync($"Do you really want to buy {Car.CarModel.Manufacturer} {Car.CarModel.Model} {Car.ManufactureYear}?", "Confirmation"); if (result == MessageDialogResult.Cancel) { _eventAggregator.GetEvent <OpenCarListEvent>().Publish(new OpenCarListEventArgs()); return; } //injecting data from another repository is not allowed when save changes is reqired //additional function is created in person repository CarSale cars_Sold = new CarSale { SalePrice = Price, Date = Date }; await _personRepository.AddNewSaleAsync(Car.Id, Customer.Id, cars_Sold); await _carRepository.CarIsSoldAsync(Car.Id); _eventAggregator.GetEvent <OpenCarListEvent>().Publish(new OpenCarListEventArgs()); }
public void ShowMessageDialog(string message, Action callBackSuccess = null) { MessageDialogService.Create(message, c => { callBackSuccess?.Invoke(); LoadingService.LoadingStop(); }, null); }
private void App_UnhandledException(object sender, Windows.UI.Xaml.UnhandledExceptionEventArgs e) { LoadingService.LoadingStart(); MessageDialogService.Create("Error Global. Contacte al administrador", c => { LoadingService.LoadingStop(); NavigationService.NavigatePop <Dashboard>(); }, null); }
protected async override void OnDeleteExecute() { var result = await MessageDialogService.ShowOkCancelDialogAsync($"Do you really want to delete the user {User.FullName}?", "Question"); if (result == MessageDialogResult.OK) { _userRepository.Remove(User.Model); await _userRepository.SaveAsync(); RaiseDetailDeletedEvent(User.Id); } }
private async void BtnRechazar_Click(object sender, RoutedEventArgs e) { var userId = IdentityServices.Instance.GetUserLogged().Id; MessageDialogService.Create("Si rechaza las normas del concurso, estara rechanzado la inscripción al concurso. ¿Está seguro que desea continuar?", async c => { await new ConcursoServices().RechazarTerminosYCondiciones(_concursoId, userId); NavigationService.Navigate <ListConcursosOfertarPage>(); }, x => { }); }
private void ApbCancel_OnClick(object sender, RoutedEventArgs e) { LoadingService.LoadingStart(); MessageDialogService.Create("¿Esta seguro que desea descargar los cambios?", c => { LoadingService.LoadingStop(); NavigationService.NavigatePop <IdiomasSettingsPage>(); }, command => { }); }
private async void BtnAcept_Click(object sender, RoutedEventArgs e) { var userId = IdentityServices.Instance.GetUserLogged().Id; await new ConcursoServices().AceptarTerminosYCondiciones(_concursoId, userId); MessageDialogService.Create("Gracias por aceptar los terminos y condiciones, ahora puede realiar su oferta.", c => { NavigationService.Navigate <ListConcursosOfertarPage>(); }, x => { }); }
protected override void OnDeleteExecute() { var result = MessageDialogService.ShowOkCancelDialog($"Do you really want to delete meeting {Meeting.Title}?", "Question"); if (result == MessageDialogResult.OK) { _meetingRepository.Remove(Meeting.Model); _meetingRepository.SaveAsync(); RaiseDetailDeletedEvent(Meeting.Id); } }
protected async override void OnDeleteExecute() { var result = await MessageDialogService.ShowOkCancelDialogAsync($"Наистина ли искате да изтриете {Workout.Title}?", "Въпрос"); if (result == MessageDialogResult.OK) { _workoutRepository.Remove(Workout.Model); await _workoutRepository.SaveAsync(); RaiseDetailDeletedEvent(Workout.Id); } }
protected override async void OnDeleteExecute() { var result = await MessageDialogService.ShowOkCancelDialogAsync($"Do you Really want to delete the {Meeting.Title}?", "Question"); if (result == MessageDialogResult.Affirmative) { _meetingRepository.Remove(Meeting.Model); await _meetingRepository.SaveAsync(); RaiseDetailDeletedEvent(Meeting.Id); } }
protected override async Task OnDeleteExecute() { var result = await MessageDialogService.ShowOKCancelDialogAsync($"Do you really want to delete the friend {Meeting.Title}", "Question"); if (result == MessageDialogResult.OK) { _meetingRepository.Remove(Meeting.Model); await _meetingRepository.SaveAsync(); RaiseDetailDeletedEvent(Meeting.Id); } }
public static async Task LoadData() { try { // Get all countries covid cases await App.CovidService.GetLocationsAsync(); } catch (Exception ex) { MessageDialogService.Display("Error", "Could not get latest informations! check your internet connection."); } }
private async Task CheckPipeHeight2() { if (Pipe.PipeHeight2 <= 0) { await MessageDialogService.ShowInfoDialogAsync( $"Введена недопустимая высота трубы h1. При угле кровли {Pipe.RoofAngle} град., высота трубы h1 должна быть больше. " + $"Уточните значение h1 и нажмите кнопку \"Рассчитать\""); Pipe.PipeHeight2 = 0; // Do smthg with PipeHeight1 and re-count PipeHeight2 } }
private async Task CheckRoofAngle() { if (Pipe.RoofAngle < 15 || Pipe.RoofAngle > 50) { await MessageDialogService.ShowInfoDialogAsync( $"Введен недопустимый угол кровли. Значение угла кровли должно быть в пределах 15-80 град. " + $"Уточните значение угла кровли и нажмите кнопку \"Рассчитать\""); Pipe.RoofAngle = 15; Pipe.PipeHeight2 = 0; } }
public DesignTimeViewModelLocator() { var ingredientRepository = new IngredientRepository(new DesignTimeDbContextFactory()); var recipeRepository = new RecipeRepository(new DesignTimeDbContextFactory()); var mediator = new Mediator(); var messageDialogService = new MessageDialogService(); IngredientAmountDetailViewModel = new IngredientAmountDetailViewModel(ingredientRepository, mediator); IngredientListViewModel = new IngredientListViewModel(ingredientRepository, mediator); RecipeListViewModel = new RecipeListViewModel(recipeRepository, mediator); IngredientDetailViewModel = new IngredientDetailViewModel(ingredientRepository, messageDialogService, mediator); }
protected override async void OnDeleteExecute() { var result = await MessageDialogService.ShowOkCandelDialogAsync("Отменить внесенные изменения?", "Впорос"); if (result == MessageDialogResult.OK) { _meetingRepository.Delete(Meeting.Model); await _meetingRepository.SaveAsync(); RaiseDetailDeletedEvent(Meeting.Id); } }