using System;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using SvetoforVKBot.Models.Updates;
using VkNet;
using VkNet.Model.RequestParams;

namespace SvetoforVKBot.Models.Commands.Registration
{
    public class SelectDateNavigationCommand : Command
    {
        public override string Name => "{\"button\":\"selectDateNavigation-";

        public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
        {
        }

        public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
        {
            MessagesSendParams @params = new MessagesSendParams();
            var chatId = update.@object.message.from_id;
            Regex regex = new Regex("[^0-9]");

            try
            {
                string[] payload = update.@object.message.payload.Split('-');
                payload[1] = payload[1].Replace("\"}", "");
                DateTime curDateTime = DateTime.Parse(payload[1]);

                ShowCalendar showCalendar = new ShowCalendar();
                showCalendar.Execute(update, client, db, curDateTime);
            }
            catch (Exception ee)
            {
                @params.Message = "‼Ошибка в SelectDateNavigationCommand: " + ee.Message;
                @params.Attachments = null;
                @params.Keyboard = null;
                @params.UserId = 59111081;
                @params.RandomId = GetRandomId();
                client.Messages.SendAsync(@params);
            }
        }
    }
}