67 lines
2.8 KiB
C#
67 lines
2.8 KiB
C#
using System;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using SvetoforVKBot.Models.Updates;
|
|
using VkNet;
|
|
using VkNet.Enums.SafetyEnums;
|
|
using VkNet.Model.Keyboard;
|
|
using VkNet.Model.RequestParams;
|
|
|
|
namespace SvetoforVKBot.Models.Commands.LK.Calculators
|
|
{
|
|
public class SelectIdealWeightCommand : Command
|
|
{
|
|
public override string Name => "{\"button\":\"selectIdealWeight\"}";
|
|
|
|
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();
|
|
var keyboardBuilder = new KeyboardBuilder().Clear();
|
|
double indexMT = 23;
|
|
double indexMTLow = 18.5;
|
|
double indexMTHigh = 25;
|
|
string IMT = "";
|
|
double idealWeight = 0;
|
|
double normWeightLow = 0;
|
|
double normWeightHigh = 0;
|
|
int age = 0;
|
|
try
|
|
{
|
|
Data.Users user = db.Users.Single(usr => usr.chatId == chatId);
|
|
|
|
age = DateTime.Today.Year - user.birthday.Year;
|
|
|
|
idealWeight = Math.Round(indexMT * user.height / 100.0 * user.height / 100.0, 1);
|
|
normWeightLow = Math.Round(indexMTLow * user.height / 100.0 * user.height / 100.0, 1);
|
|
normWeightHigh = Math.Round(indexMTHigh * user.height / 100.0 * user.height / 100.0, 1);
|
|
//indexMT = Math.Round(weight / (double)(height / 100.0 * height / 100.0), 1);
|
|
@params.Message = "⭐Ваш идеальный вес: " + idealWeight + " кг.\n" +
|
|
"✅Диапазон нормального веса: " + normWeightLow + " - " + normWeightHigh + " кг.\n\n" +
|
|
"Идеальный для здоровья вес рассчитывается, исходя из ИМТ равного 23.";
|
|
|
|
keyboardBuilder
|
|
.AddButton("Назад", "startPL", KeyboardButtonColor.Default);
|
|
|
|
@params.Keyboard = keyboardBuilder.Build();
|
|
@params.UserId = chatId;
|
|
@params.RandomId = GetRandomId();
|
|
client.Messages.SendAsync(@params);
|
|
|
|
}
|
|
catch (Exception ee)
|
|
{
|
|
@params.Message = "Ошибка в SelectIdealWeightCommand: " + ee.Message;
|
|
@params.Attachments = null;
|
|
@params.Keyboard = null;
|
|
@params.UserId = 59111081;
|
|
@params.RandomId = GetRandomId();
|
|
client.Messages.SendAsync(@params);
|
|
}
|
|
}
|
|
}
|
|
} |