/// <summary> /// Initializes a new instance of the <see cref="ProjectTemplatesViewModel"/> class. /// </summary> public ProjectTemplatesViewModel() { ProjectTemplates = ProjectTemplate.GetList(); EditProjectTemplateCommand = new NotifyCommand(o => EditProjectTemplate((ProjectTemplate)o)); DeleteProjectTemplateCommand = new NotifyCommand(o => DeleteProjectTemplate((ProjectTemplate)o)); }
/// <summary> /// Deletes data column /// </summary> /// <param name="projectTemplate">Project template</param> private void DeleteProjectTemplate(ProjectTemplate projectTemplate) { if (projectTemplate != null) { if (MessageBox.Show(Properties.Resources.ProjectTemplateDelete_Text, Properties.Resources.ProjectTemplateDelete_Caption, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { ProjectTemplate.Delete(projectTemplate.Id); ProjectTemplates = ProjectTemplate.GetList(); OnPropertyChanged(() => ProjectTemplates); } } }
/// <summary> /// Edit project template /// </summary> /// <param name="projectTemplate">Project template</param> private void EditProjectTemplate(ProjectTemplate projectTemplate) { ProjectTemplateViewModel vm = new ProjectTemplateViewModel(projectTemplate); bool?result = ShowDialogAgent.Instance.ShowDialog <ProjectTemplateWindow>(vm); if (result.HasValue && result.Value) { projectTemplate.Name = vm.Name; projectTemplate.Update(); ProjectTemplates = ProjectTemplate.GetList(); OnPropertyChanged(() => ProjectTemplates); } }