示例#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!");
        }
示例#2
0
        async Task RegisterFormDialogResumedAsync(IDialogContext context, IAwaitable <RegisterForm> result)
        {
            var         mtgState = new MeetingState();
            MeetingData mtgData  = await mtgState.GetAsync(context.Activity) ?? new MeetingData();

            RegisterForm form = await result;

            mtgData.UserDBID      = form.UserID;
            mtgData.UserChannelID = context.Activity.From.Id;

            MtgData = mtgData;
            //await mtgState.UpdateAsync(context.Activity, mtgData);

            context.Wait(MessageReceivedAsync);
        }