예제 #1
0
        private async Task DeleteProject(ProjectOutDto project)
        {
            var response = await _projectRepository.DeleteProject(project);

            ProjectsList.Remove(project);
            StateHasChanged();
        }
예제 #2
0
        public ProjectsViewModel(IProjectService projects, IAppStateService state, IDialogService dialog)
        {
            _projects = projects;
            _state    = state;
            _dialog   = dialog;


            _state.KeysChanged += async(s, e) =>
            {
                await LoadAsync();
            };

            this.ShowCreate = new RelayCommand(() => { IsCreating = true; });

            this.SelectProject = new RelayCommand <Project>((project) => {
                if (project == null)
                {
                    return;
                }

                _state.CurrentProject = project;
                _state.SetCurrentPackage(null);
                ApplicationData.Current.LocalSettings.Values["LastProject"] = _state.CurrentProject.Name;
            });

            this.CreateProject = new RelayCommand <string>(async(project) => {
                if (string.IsNullOrWhiteSpace(project))
                {
                    return;
                }

                var newProject = await _projects.CreateProjectAsync(project);
                ProjectsList.Add(newProject);
                CurrentProject = newProject;
                IsCreating     = false;
            });
            this.ManageProjects = new RelayCommand(async() => {
                await _dialog.OpenAsync(DialogKeys.ManageProjects, this);
            });
            this.DeleteProject = new RelayCommand <Project>(async(project) => {
                Debug.WriteLine($"Delete {project.Name}");
                var confirm = await _dialog.ConfirmAsync("Confirm", $"Are you sure you want to delete {project.Name}?", "Yes", "No");

                if (!confirm)
                {
                    return;
                }

                await _projects.DeleteProjectAsync(project.Id);
                if (CurrentProject.Id == project.Id)
                {
                    CurrentProject = null;
                }
                ProjectsList.Remove(project);
            });
        }
예제 #3
0
 //Удаление проекта project из потока, isSetup = false - удаление при настройке другого потока
 public void DeleteProject(Project project)
 {
     AddEvent("Удаление проекта", project.Code);
     try
     {
         foreach (var p in project.Providers.Values)
         {
             p.Projects.Remove(project.Code);
             if (p.Projects.Count == 0)
             {
                 ProvidersDic.Remove(p.Name);
             }
         }
         Projects.Remove(project.Code);
         ProjectsList.Remove(project);
     }
     catch (Exception ex)
     {
         AddError("Ошибка при удалении проекта", ex);
     }
     MakeProviders();
     MakeProjectString();
 }