using System; using System.Data.SqlClient; using SvetoforVKBot.Models.Updates; using VkNet; using VkNet.Enums.SafetyEnums; using VkNet.Model.Keyboard; using VkNet.Model.RequestParams; using Newtonsoft.Json; using VkNet.Enums.Filters; using VkNet.Model.Attachments; using System.Collections.Generic; using System.Threading; using SvetoforVKBot.Models.Dop; using SvetoforVKBot.Models.Commands; using System.Text.RegularExpressions; using System.Linq; namespace SvetoforVKBot.Models.Commands.Registration { public class SelectChildAgeCommand : Command { public override string Name => "{\"button\":\"selectChildAge-"; 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(); Regex regex = new Regex("[^0-9]"); try { string[] payload = update.@object.message.payload.Split('-'); int child = Convert.ToInt32(regex.Replace(payload[1], "")); var user = db.Users.Single(usr => usr.chatId == chatId); user.tag = "Подписчик - Регистрация"; user.child = child; db.SaveChanges(); SelectAgreementCommand selectAgreement = new SelectAgreementCommand(); selectAgreement.ExecutePL(update, client, db); } catch (Exception ee) { @params.Message = "Ошибка в SelectChildAgeCommand: " + ee.Message; @params.Attachments = null; @params.Keyboard = null; @params.UserId = 59111081; @params.RandomId = GetRandomId(); client.Messages.SendAsync(@params); } } } }