Добавьте файлы проекта.

This commit is contained in:
Daria
2021-10-19 06:04:52 +03:00
parent 6ee25d0f59
commit eab3081ec2
187 changed files with 100839 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
using SvetoforVKBot.Models.Updates;
using VkNet;
using VkNet.Model.RequestParams;
using VkNet.Model.Keyboard;
using System.Collections.ObjectModel;
using System.Security.Cryptography;
using VkNet.Enums.SafetyEnums;
using SvetoforVKBot.Models.Dop;
using System.Linq;
namespace SvetoforVKBot.Models.Commands.LK
{
public class GetWeightCommand
{
public void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
{
MessagesSendParams @params = new MessagesSendParams();
var chatId = update.@object.message.from_id;
int i = 0;
var keyboardBuilder = new KeyboardBuilder().Clear();
try
{
if (int.TryParse(update.@object.message.text.Trim(), out int weight))
{
var user = db.Users.Single(usr => usr.chatId == chatId);
user.weight = weight;
user.tag = "Личный кабинет - Данные";
db.SaveChanges();
/*SqlCommand editUser = new SqlCommand("UPDATE Users SET tag = @tag, weight = @weight WHERE chatId = @chatId;", Con);
editUser.Parameters.AddWithValue("@chatId", chatId);
editUser.Parameters.AddWithValue("@tag", "Личный кабинет - Данные");
editUser.Parameters.AddWithValue("@weight", weight);
editUser.ExecuteNonQuery();*/
SelectEditDataCommand selectEditData = new SelectEditDataCommand();
selectEditData.Execute(update, client, db);
}
else
{
@params.UserId = chatId;
@params.Message = "Вы некорректно ввели вес 🤔 Введите, пожалуйста, число (до 3 символов).";
@params.RandomId = GetRandomId();
client.Messages.SendAsync(@params);
}
}
catch (Exception ee)
{
@params.Message = "‼Ошибка в GetWeightCommand: " + ee.Message;
@params.Attachments = null;
@params.Keyboard = null;
@params.UserId = 59111081;
@params.RandomId = GetRandomId();
client.Messages.SendAsync(@params);
}
}
private static readonly RandomNumberGenerator Rng = RandomNumberGenerator.Create();
public int GetRandomId()
{
var intBytes = new byte[4];
Rng.GetBytes(intBytes);
return BitConverter.ToInt32(intBytes, 0);
}
}
}