コード例 #1
0
        private void btnRemove_Click(object sender, RoutedEventArgs e)
        {
            if (!Views.MessageBox.ShowDialogBox("删除该类型会将旗下所有的回复内容进行删除, 是/否?"))
            {
                return;
            }

            if (this.DataContext is FastReplyViewModel vm)
            {
                Button             btn   = sender as Button;
                FastReplyTypeModel model = btn.DataContext as FastReplyTypeModel;
                vm.TypeItems.Remove(model);

                string typeName     = model.TypeName;
                int    cateId       = model.TypeId;
                int    editType     = 3;
                int    categoryType = vm.IsCommonReply ? 1 : 2;

                var result = SDKClient.SDKClient.Instance.PostQuickReplyCategoryedit(editType, cateId, typeName, categoryType);
                if (!result.success)
                {
                    AppData.MainMV.TipMessage = "删除类型失败";
                }
                else
                {
                    AppData.MainMV.TipMessage = "删除类型成功";
                }
            }
        }
コード例 #2
0
        private void btnAddType_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(this.txtAddTypeName.Text))
            {
                AppData.MainMV.TipMessage = "类型名称不能为空";
                return;
            }

            if (this.DataContext is FastReplyViewModel vm)
            {
                string typeName = this.txtAddTypeName.Text.Trim();

                if (vm.TypeItems.Any(x => x.TypeName == typeName))
                {
                    AppData.MainMV.TipMessage = "类型名称重复,请重新输入";
                    return;
                }

                int editType     = 1;
                int categoryType = vm.IsCommonReply ? 1 : 2;
                var result       = SDKClient.SDKClient.Instance.PostQuickReplyCategoryedit(editType, 0, typeName, categoryType);
                if (result.success)
                {
                    FastReplyTypeModel typeModel = new FastReplyTypeModel()
                    {
                        TypeId   = result.id,
                        TypeName = typeName,
                    };
                    FastReplyContentModel contentModel = new FastReplyContentModel();
                    typeModel.TypeItems.Add(contentModel);

                    vm.TypeItems.Add(typeModel);

                    AppData.MainMV.TipMessage = "新增回复类型成功";
                }
                else
                {
                    AppData.MainMV.TipMessage = "新增回复类型失败";
                }
            }
        }