upd Authentification
This commit is contained in:
@@ -15,6 +15,7 @@ using SvetoforVKBot.Models.Commands.LK;
|
||||
using SvetoforVKBot.Models.Commands.LK.SportsLK;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using SvetoforVKBot.Models.Commands.Registration;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands
|
||||
{
|
||||
@@ -36,89 +37,7 @@ namespace SvetoforVKBot.Models.Commands
|
||||
var user = client.Users.Get(ids, ProfileFields.Sex);
|
||||
var gender = Convert.ToInt32(user[0].Sex);
|
||||
var listButtons = new List<ReadOnlyCollection<MessageKeyboardButton>>();
|
||||
Uri URL = new Uri("https://www.vyatsu.ru/");
|
||||
#region UTM
|
||||
/*
|
||||
utm = update.@object.message.@ref;
|
||||
|
||||
if (utm != "" && utm != null)
|
||||
{
|
||||
if (int.TryParse(utm, out int refer))
|
||||
{
|
||||
if (refer != chatId)
|
||||
{
|
||||
int referId = 1;
|
||||
|
||||
//Проверяем приглашали ли этого пользователя раннее
|
||||
getUser = new SqlCommand("SELECT referId FROM Users WHERE chatId = @chatId;", Con);
|
||||
getUser.Parameters.AddWithValue("@chatId", chatId);
|
||||
rgetUser = getUser.ExecuteReader();
|
||||
rgetUser.Read();
|
||||
int uReferId = Convert.ToInt32(rgetUser["referId"]);
|
||||
rgetUser.Close();
|
||||
|
||||
if (uReferId == 0) // 0 - не приглашали
|
||||
{
|
||||
//Ищем пользователя, который пригласил
|
||||
SqlCommand getRefer = new SqlCommand("SELECT chatId FROM Users WHERE chatId = @refer;", Con);
|
||||
getRefer.Parameters.AddWithValue("@refer", refer);
|
||||
SqlDataReader rgetRefer = getRefer.ExecuteReader();
|
||||
if (rgetRefer.HasRows) // если пользователь существует
|
||||
{
|
||||
rgetRefer.Close();
|
||||
|
||||
SqlCommand updReferId = new SqlCommand("UPDATE Users SET referId = @referId WHERE chatId = @chatId;", Con);
|
||||
updReferId.Parameters.AddWithValue("@chatId", chatId);
|
||||
updReferId.Parameters.AddWithValue("@referId", refer);
|
||||
updReferId.ExecuteNonQuery();
|
||||
|
||||
selectQuestRoom.ExecutePL(update, client, Con);
|
||||
return;
|
||||
}
|
||||
else
|
||||
rgetRefer.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
selectQuestRoom.ExecutePL(update, client, Con);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
selectQuestRoom.ExecutePL(update, client, Con);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SourceUpdate sourceUpdate = new SourceUpdate();
|
||||
sourceUpdate.Execute(update, client, Con);
|
||||
|
||||
switch (utm)
|
||||
{
|
||||
case "afisha":
|
||||
SelectEventsCommand selectEvents = new SelectEventsCommand();
|
||||
selectEvents.ExecutePL(update, client, Con);
|
||||
return;
|
||||
|
||||
case "quest":
|
||||
selectQuestRoom.ExecutePL(update, client, Con);
|
||||
return;
|
||||
|
||||
case "project":
|
||||
SelectProjectOfficeCommand selectProjectOffice = new SelectProjectOfficeCommand();
|
||||
selectProjectOffice.ExecutePL(update, client, Con);
|
||||
return;
|
||||
|
||||
case "faq":
|
||||
SelectOSCommand selectOS = new SelectOSCommand();
|
||||
selectOS.ExecutePL(update, client, Con);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
#endregion UTM
|
||||
Uri URL = new Uri("https://www.vyatsu.ru/");
|
||||
|
||||
var getUser = db.Users.Single(usr => usr.chatId == chatId);
|
||||
int reg = getUser.reg;
|
||||
@@ -130,17 +49,15 @@ namespace SvetoforVKBot.Models.Commands
|
||||
switch (reg)
|
||||
{
|
||||
case 1:
|
||||
if (activityKind == 2 || activityKind == 3)
|
||||
if (getUser.isAuthorized == 1)
|
||||
{
|
||||
ShowLKCommand showLK = new ShowLKCommand();
|
||||
showLK.Execute(update, client, db);
|
||||
}
|
||||
else // спортсмены
|
||||
else
|
||||
{
|
||||
ShowLKCommand showLK = new ShowLKCommand();
|
||||
showLK.Execute(update, client, db);
|
||||
//ShowSportsLKCommand showSportsLK = new ShowSportsLKCommand();
|
||||
//showSportsLK.Execute(update, client, Con);
|
||||
SelectParticipateCommand selectParticipate = new SelectParticipateCommand();
|
||||
selectParticipate.ExecutePL(update, client, db);
|
||||
}
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user