using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Data.SqlClient; using System.Linq; using Newtonsoft.Json; using SvetoforVKBot.Models.Updates; using VkNet; using VkNet.Enums.SafetyEnums; using VkNet.Model.Keyboard; using VkNet.Model.RequestParams; namespace SvetoforVKBot.Models.Commands.Registration { public class SelectRegVkNameCommand : Command { public override string Name => "{\"button\":\"selectRegVkName\"}"; public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db) { } public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db) { var chatId = update.@object.message.from_id; MessagesSendParams @params = new MessagesSendParams(); var keyboardBuilder = new KeyboardBuilder().Clear(); try { var user = db.Users.Single(usr => usr.chatId == chatId); user.tag = "Регистрация - Возраст"; //user.fio = user.firstName + " " + user.lastName; db.SaveChanges(); @params.Message = "2 шаг из 4. Напиши возраст одним числом, например, 19. \n"; keyboardBuilder .AddButton("Отменить", "selectRegistration", KeyboardButtonColor.Default); @params.Keyboard = keyboardBuilder.Build(); @params.UserId = chatId; @params.RandomId = GetRandomId(); client.Messages.SendAsync(@params); } catch (Exception ee) { @params.Message = "Ошибка в ContinueRegCommand: " + ee.Message; @params.Attachments = null; @params.Keyboard = null; @params.UserId = 59111081; @params.RandomId = GetRandomId(); client.Messages.SendAsync(@params); } } } }