private async void ExecuteDeleteProjectCommand(ProjectViewModel arg) { ConfirmationServiceArgs args = new ConfirmationServiceArgs(Strings.Confirm, string.Format(Strings.DoYouReallyWantToDeleteProjectXXX, arg.Model.Name), Strings.Yes, Strings.No); if (!await ViewServices.Execute <IConfirmationService, bool>(args)) { return; } arg.CurrentChanged -= Proj_CurrentChanged; Projects.Remove(arg); ProjectRepo.Delete(arg.Model); if (!Projects.Contains(CurrentProject)) { CurrentProject = Projects.FirstOrDefault(); if (CurrentProject != null) { CurrentProject.IsCurrent = true; } } MessengerInstance.Send(new NotificationMessage(Strings.ProjectDeleted)); }
private async Task OnSaveProject() { if (_selectedProject.ValidateModel()) { try { if (SelectedProject.ProjectId == Guid.Empty) { SelectedProject = await _adminService.CreateProjectAsync(_selectedProject); _canCreateNewProject = await _adminService.CanCreateNewProject(Company.CompanyId); NewProject.RaiseCanExecuteChanged(); } else { await _adminService.UpdateProjectAsync(_selectedProject); } if (!Projects.Contains(SelectedProject)) { Projects.Add(SelectedProject); } IsProjectEditorVisible = false; } catch (TimeoutException timeoutEx) { _eventAggregator.GetEvent <TimeoutErrorEvent>().Publish(timeoutEx); } } }
public Participant AddProject(Project project) { if (Projects.Contains(project)) { throw new DuplicateException($"{nameof(project)} already exist"); } Projects.Add(project); return(this); }
public void removeProject(Project project, User currUser) { if (Projects.Contains(project)) { Projects.Remove(project); } else { throw new DoNotContainElementException(); } }
public void AddProjects(params CsProj[] csProjs) { foreach (CsProj proj in csProjs) { if (!Projects.Contains(proj)) { Projects.Add(proj); AddProjectToFolder(proj); } } }
private void OnCancelEditProject() { if (Projects.Contains(SelectedProject)) { SelectedProject.Name = originalProjectTitle; } else { SelectedProject = null; } IsProjectEditorVisible = false; }
// Crawl for projects public void CrawlDirectories() { Crawler c = new Crawler(Directories); var crawled = c.Crawl(); foreach (var cr in crawled) { if (!Projects.Contains(cr)) { Projects.Add(cr); } } SProjects.Save(Projects, ProjectsSave); LoadProjects(); }
public void removeProject(Project project, User currUser) { if (!currUser.Admin && !(currUser == this)) { throw new InvalidAccessException(); } else if (!Projects.Contains(project)) { throw new DoNotContainElementException(); } else { if (project.Users.Contains(this)) { project.removeUser(this, currUser); } Projects.Remove(project); } }
public virtual bool HasProject(Project project) { return(Projects.Contains <Project>(project)); }
public async Task <bool> SetActiveProjectAsync(IProject project) { using (await _commonAsyncLock.LockAsync()) { var activeProject = ActiveProject; if (project != null && !Projects.Contains(project)) { return(false); } var activeProjectLocation = activeProject?.Location; var newProjectLocation = project?.Location; if (string.Equals(activeProjectLocation, newProjectLocation)) { return(false); } Log.Info(project != null ? $"Activating project '{project.Location}'" : "Deactivating currently active project"); var eventArgs = new ProjectUpdatingCancelEventArgs(activeProject, project); _projectStateSetter.SetProjectDeactivating(activeProject?.Location, true); _projectStateSetter.SetProjectActivating(project?.Location, true); await ProjectActivationAsync.SafeInvokeAsync(this, eventArgs, false).ConfigureAwait(false); if (eventArgs.Cancel) { Log.Info(project != null ? $"Activating project '{project.Location}' was canceled" : "Deactivating currently active project"); _projectStateSetter.SetProjectActivating(project?.Location, false); await ProjectActivationCanceledAsync.SafeInvokeAsync(this, new ProjectEventArgs(project)).ConfigureAwait(false); return(false); } Exception exception = null; try { ActiveProject = project; } catch (Exception ex) { exception = ex; } if (exception != null) { Log.Error(exception, project != null ? $"Failed to activate project '{project.Location}'" : "Failed to deactivate currently active project"); _projectStateSetter.SetProjectActivating(project?.Location ?? string.Empty, false); await ProjectActivationFailedAsync.SafeInvokeAsync(this, new ProjectErrorEventArgs(project, exception)).ConfigureAwait(false); return(false); } _projectStateSetter.SetProjectDeactivating(activeProject?.Location, false); _projectStateSetter.SetProjectActivating(project?.Location, false); await ProjectActivatedAsync.SafeInvokeAsync(this, new ProjectUpdatedEventArgs(activeProject, project)).ConfigureAwait(false); Log.Debug(project != null ? $"Activating project '{project.Location}' was canceled" : "Deactivating currently active project"); return(true); } }