public async Task Reply(TelegramBotClient client, Update hook, JobBotDbContext ctx = null) { var user = await ctx.Users.FirstOrDefaultAsync(x => x.ChatId == hook.ChatId()); user.SearchEnabled = true; ctx.Users.Update(user); await ctx.SaveChangesAsync(); }
public async Task Reply(TelegramBotClient client, Update hook, JobBotDbContext ctx = null) { var user = await ctx.Users.FirstOrDefaultAsync(x => x.ChatId == hook.ChatId()); var preferences = hook.Message.Text.TrimStart(UpdatePreferencesCommand.ToCharArray()).Trim(); user.Preferences = preferences; ctx.Users.Update(user); await ctx.SaveChangesAsync(); await client.SendTextMessageAsync(hook.ChatId(), "preferences changed to " + preferences); }
public async Task EnsureRegistered(Update hook) { var userExist = _context.Users.FirstOrDefault(x => x.ChatId == hook.ChatId()); if (userExist == null) { var user = new Data.Entities.User() { ChatId = hook.ChatId(), SearchEnabled = true }; _context.Users.Add(user); await _context.SaveChangesAsync(); } }