我想在我的RootDialog中显示一个DialogForm。我试图通过从 dialogs 调用表单来做到这一点。但是,我的问题是我有一个由实体框架生成的模型类,其中包含一些关于主键(或外键)的字段,我不希望我的客户为其输入输入。所以我的问题是如何制作一个 DialogForm 只要求我的客户输入我想要的字段?这是我的模型类:
[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);
}
}