我想在 RootDialog 中显示 DialogForm 。我试图像calling forms from dialogs这样做。但是,我的问题是我有一个由Entity Framework生成的模型类,它包含一些关于主键(或外键)的字段,我不希望我的客户输入它。所以我的问题是如何制作一个只需要让我的客户输入我想要的字段的DialogForm? 这是我的Model类:
[Serializable]
public partial class BOT_CUSTOMERINFO
{
public int CUSTOMER_ID { get; set; }
public Nullable<int> DOMAIN_ID { get; set; }
public string NAME { get; set; }
public string EMAIL { get; set; }
public string PHONE { get; set; }
public Nullable<int> RECORD_STATUS { get; set; }
public static IForm<BOT_CUSTOMERINFO> BuildForm()
{
return new FormBuilder<BOT_CUSTOMERINFO>()
.Message("Vui lòng cung cấp thông tin")
.Field(nameof(NAME))
.Field(nameof(EMAIL))
.Field(nameof(PHONE))
.Field(new FieldReflector<BOT_CUSTOMERINFO>(nameof(CUSTOMER_ID)).SetActive((state) => false))
.Build();
}
}
因此我曾经称之为FormDialog:
private BuildFormDelegate<Models.FormDialog_Models.CustomerInfoFormModel> MakeCustomerInfoForm;
internal void CustomerInfoDialog(BuildFormDelegate<Models.BOT_CUSTOMERINFO> makeCustomerInfoForm)
{
this.MakeCustomerInfoForm = makeCustomerInfoForm;
}
public async Task ResumeAfterChooseQuestion(IDialogContext context, IAwaitable<BOT_QUESTION> result)
{
var value = await result;
if(value != null)
{
BotDBEntities DbContext = new BotDBEntities();
if(DbContext.BOT_ANSWER.Any(answer => answer.QUESTION_ID == value.QUESTION_ID))
{
List<BOT_ANSWER> ListAnswer = DbContext.BOT_ANSWER.Where(answer => answer.QUESTION_ID == value.QUESTION_ID).ToList();
await ShowListAnswer(context, ListAnswer);
//PromptDialog.Choice(context, this.ResumeAfterChooseAnswer,ListAnswer, "Click để chọn:", "Không hợp lệ", 3, PromptStyle.Auto);
}
if(DbContext.BOT_QUESTION.Any(question => question.PREVQUESTION_ID == value.QUESTION_ID))
{
List<BOT_QUESTION> ListQuestion = DbContext.BOT_QUESTION.Where(question => question.PREVQUESTION_ID == value.QUESTION_ID).ToList();
await this.ShowListQuestion(context, ListQuestion);
}
if(value.QUESTION_TYPE.Value == 1)
{
var customerInfoForm = new FormDialog<Models.BOT_CUSTOMERINFO>(new Models.BOT_CUSTOMERINFO(), MakeCustomerInfoForm, FormOptions.PromptInStart);
context.Call(customerInfoForm, CustomerInfoFormCompleted);
// var customerInfoForm = new FormDialog<Models.FormDialog_Models.CustomerInfoFormModel>(new Models.FormDialog_Models.CustomerInfoFormModel(),MakeCustomerInfoForm, FormOptions.PromptInStart);
// context.Forward(customerInfoForm, CustomerInfoFormCompleted);
// context.Call(customerInfoForm, CustomerInfoFormCompleted);
//context.Call<Idia<BOT_CUSTOMERINFO>>(BOT_CUSTOMERINFO.BuildForm(), CustomerInfoFormCompleted);
}
}
else
{
context.Wait(this.MessageReceiveAsync);
}
}
答案 0 :(得分:1)
在FormBuilder<BOT_CUSTOMERINFO>
的声明中,您可以使用Advanced.Field.SetActive停用这些字段。
new FormBuilder<BOT_CUSTOMERINFO>
.Field(new FieldReflector<BOT_CUSTOMERINFO>(nameof(CUSTOMER_ID))
.SetActive((state) => false);