0

I want to display a DialogForm in my RootDialog. I've tried to do it by doing like calling forms from dialogs. However, my problem here is I have a model class generated by Entity Framework which contains some fields about primary key (or Foreign key) that I don't want my client to enter input for it. So my question is how can I make a DialogForm that just ask my clients to enter the fields that I want to? Here's my Model class:

[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();

    }

}

And hence what I've used to call 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);
        }

    }
Community
  • 1
  • 1
Justin Van
  • 307
  • 4
  • 16

1 Answers1

1

In the declaration of your FormBuilder<BOT_CUSTOMERINFO> you can deactivate those fields, using the Advanced.Field.SetActive.

new FormBuilder<BOT_CUSTOMERINFO>
.Field(new FieldReflector<BOT_CUSTOMERINFO>(nameof(CUSTOMER_ID))
      .SetActive((state) => false);
Ezequiel Jadib
  • 14,767
  • 2
  • 38
  • 43