70 lines
2.5 KiB
C#
70 lines
2.5 KiB
C#
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 System.Text.RegularExpressions;
|
|
using SvetoforVKBot.Models.Commands.LK;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace SvetoforVKBot.Models.Commands.Registration
|
|
{
|
|
public class SelectSportsCommand : Command
|
|
{
|
|
public override string Name => "{\"button\":\"selectSports-";
|
|
|
|
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;
|
|
var keyboardBuilder = new KeyboardBuilder().Clear();
|
|
Regex regex = new Regex("[^0-9]");
|
|
//int i = 1;
|
|
try
|
|
{
|
|
string[] payload = update.@object.message.payload.Split('-');
|
|
int sportId = Convert.ToInt32(regex.Replace(payload[1], ""));
|
|
//int sportId = Convert.ToInt32(regex.Replace(payload[2], ""));
|
|
var user = db.Users.Single(usr => usr.chatId == chatId);
|
|
|
|
if (user.reg == 0)
|
|
{
|
|
user.tag = "Регистрация - Дни";
|
|
user.sportId = sportId;
|
|
db.SaveChanges();
|
|
|
|
ShowSportDays showSportDays = new ShowSportDays();
|
|
showSportDays.Execute(update, client, db);
|
|
}
|
|
else
|
|
{
|
|
user.tag = "Личный кабинет - Данные";
|
|
user.sportId = sportId;
|
|
db.SaveChanges();
|
|
|
|
SelectEditDataCommand selectEditData = new SelectEditDataCommand();
|
|
selectEditData.Execute(update, client, db);
|
|
}
|
|
|
|
}
|
|
catch (Exception ee)
|
|
{
|
|
@params.Message = "Ошибка в SelectActivityCoefCommand: " + ee.Message;
|
|
@params.Attachments = null;
|
|
@params.Keyboard = null;
|
|
@params.UserId = 59111081;
|
|
@params.RandomId = GetRandomId();
|
|
client.Messages.SendAsync(@params);
|
|
}
|
|
}
|
|
}
|
|
} |