Exemplo n.º 1
0
        async Task SaveValuesAsync(IDialogContext context, RegisterForm registration)
        {
            MeetingData mtgData = await new MeetingState().GetAsync(context.Activity) ?? new MeetingData();

            //using (var ctx = new MeetingContext())
            //{
            //    User user =
            //        await
            //        (from usr in ctx.Users
            //         where usr.UserID == mtgData.UserDBID ||
            //               usr.Email == registration.Email
            //         select usr)
            //        .SingleOrDefaultAsync();

            //    if (user == null)
            //    {
            //        user = new User
            //        {
            //            Email = registration.Name,
            //            Name = registration.Email
            //        };
            //        ctx.Users.Add(user);
            //    }
            //    else
            //    {
            //        user.Name = registration.Name;
            //        user.Email = registration.Email;
            //    }

            //    await ctx.SaveChangesAsync();
            //}

            await context.PostAsync("Registration succeeded!");
        }
Exemplo n.º 2
0
        public async Task RegisterIntent(IDialogContext context, LuisResult result)
        {
            var entityValues = new List <EntityRecommendation>();

            if (result.TryFindEntity("UserName", out EntityRecommendation userNameEntity))
            {
                userNameEntity.Type = "Name";
                entityValues.Add(userNameEntity);
            }

            if (result.TryFindEntity("builtin.email", out EntityRecommendation emailEntity))
            {
                emailEntity.Type = "Email";
                entityValues.Add(emailEntity);
            }

            var registerForm    = new RegisterForm();
            var registerFormDlg = new FormDialog <RegisterForm>(
                registerForm, registerForm.BuildForm, FormOptions.PromptInStart, entityValues);

            context.Call(registerFormDlg, ResumeAfterCallAsync);
        }