private void RemoveTags(object obj) { var bindedTags = (obj as IList)?.Cast <BindedTagVM>(); if (bindedTags == null) { var bindedTag = obj as BindedTagVM; if (bindedTag == null) { return; } bindedTags = new List <BindedTagVM> { bindedTag }; } var bindedTagVms = bindedTags as IList <BindedTagVM> ?? bindedTags.ToList(); foreach (var bindedTag in bindedTagVms) { var tagToRemove = SelectedTags.FirstOrDefault(x => x.Tag.Id == bindedTag.Tag.Id && x.Value == bindedTag.Value); if (tagToRemove != null) { SelectedTags.Remove(tagToRemove); } } }
private void OnRenameTags(string newName) { ShowBusy(true); //check if new name provided is a new tag or existing var tagExistResponse = _tagService.GetTagByName(newName).Result; if (tagExistResponse.Exception != null) { StatusMessage = "Renaming tag..."; var selectedTag = SelectedTags?.FirstOrDefault(); if (selectedTag == null) { return; } StatusMessage = $"Renaming tag...{selectedTag.Name}"; var response = _tagService.RenameTag(selectedTag.Name, newName.Trim()).Result; if (response.Exception != null) { _log.Error("Error renaming tag - Data: {@data}, Exception: {@exception}", response.Data, response.Exception); ShowBusy(false); _eventAggregator.GetEvent <NotifyErrorTagAdminPage>().Publish(response.Exception.Message); return; } //trigger refresh StatusMessage = "Refreshing..."; _eventAggregator.GetEvent <TriggerGetTags>().Publish(_teamFoundationContext); } else if (tagExistResponse.Data != null) { //tag already exist ShowBusy(false); if (TaskDialog.OSSupportsTaskDialogs) { using (TaskDialog dialog = new TaskDialog()) { dialog.WindowTitle = @"Tag Admin"; dialog.MainInstruction = @"Tag name already exists!"; dialog.Content = $@"Tag '{newName}' already exists, please choose another name."; TaskDialogButton okButton = new TaskDialogButton("Try new name"); dialog.Buttons.Add(okButton); var cancelButton = new TaskDialogButton("Cancel rename"); dialog.Buttons.Add(cancelButton); var taskDialogButton = dialog.ShowDialog(); if (taskDialogButton == okButton) { OnRenameTagCommand(null); return; } if (taskDialogButton == cancelButton) { return; } } } else { var messageBoxResult = MessageBox.Show( $"Tag '{newName}' already exists, please choose another name.", "Tag Admin", MessageBoxButton.OKCancel, MessageBoxImage.Warning); if (messageBoxResult == MessageBoxResult.OK) { OnRenameTagCommand(null); return; } if (messageBoxResult == MessageBoxResult.Cancel) { return; } } } ShowBusy(false); }