private void CreateViewModelTasks(IEnumerable<TaskDefinition> tasksFromDb) { foreach (var taskDefinition in tasksFromDb) { var taskViewModel = new TaskViewModel { Name = taskDefinition.Name, ConfigurationEntries = new ObservableCollection<ConfigurationEntryViewModel>( (from setting in taskDefinition.SettingDefinitions select new ConfigurationEntryViewModel { OrderIndex = setting.OrderIndex, Name = setting.SettingName, Type = setting.Type ?? typeof (string), Value = setting.DefaultValue, HelpText = setting.HelpText }).ToArray()), Author = taskDefinition.Author, Description = taskDefinition.Description, Version = taskDefinition.Version, Webpage = taskDefinition.Webpage }; _viewModel.AddTask(taskViewModel); } }
private bool TaskAlreadyExist(TaskViewModel taskViewModel) { return AvailableTasks.Any(task => task.Name == taskViewModel.Name && task.Version == taskViewModel.Version && task.Description == taskViewModel.Description); }
partial void OnSetSelectedAvailableTask(ref TaskViewModel value);
public void AddTask(TaskViewModel taskViewModel) { if(!TaskAlreadyExist(taskViewModel)) AvailableTasks.Add(taskViewModel); }