using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Threading;
using Newtonsoft.Json;
using SvetoforVKBot.Models.Commands.Registration;
using SvetoforVKBot.Models.Updates;
using VkNet;
using VkNet.Enums.SafetyEnums;
using VkNet.Model.Attachments;
using VkNet.Model.Keyboard;
using VkNet.Model.RequestParams;

namespace SvetoforVKBot.Models.Commands.LK.EditData
{
    public class SelectUpdateSportDaysCommand : Command
    {
        public override string Name => "{\"button\":\"selectUpdateSportDays\"}";

        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();
            MessagesSendParams @params2 = new MessagesSendParams();
            var keyboardBuilder = new KeyboardBuilder().Clear();
            string msg = "";
            DateTime dt = DateTime.Now;
            string msgManager = "";
            List<int> ids = new List<int>();
            try
            {
                var user = db.Users.Single(usr => usr.chatId == chatId);
                user.sportDays = "[]";
                db.SaveChanges();

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