Добавьте файлы проекта.
This commit is contained in:
163
SvetoforVKBot/Models/Commands/LK/Cart/SelectAddToCartCommand.cs
Normal file
163
SvetoforVKBot/Models/Commands/LK/Cart/SelectAddToCartCommand.cs
Normal file
@@ -0,0 +1,163 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using Newtonsoft.Json;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Model.RequestParams;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using SvetoforVKBot.Models.Commands.LK.Menu;
|
||||
using System.Linq;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Cart
|
||||
{
|
||||
public class SelectAddToCartCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectAddToCart-";
|
||||
|
||||
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;
|
||||
string msg = "";
|
||||
double sum = 0;
|
||||
string backPL = "startPL";
|
||||
Regex regex = new Regex("[^0-9]");
|
||||
List<ProductsDostavka> products = new List<ProductsDostavka>();
|
||||
List<ProductsDostavka> souses = new List<ProductsDostavka>();
|
||||
ShowPersonalMenuCarusel showProductCaruselMain = new ShowPersonalMenuCarusel();
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
int kkals = 0;
|
||||
try
|
||||
{
|
||||
string[] payload = update.@object.message.payload.Split('-');
|
||||
int curCategory = Convert.ToInt32(regex.Replace(payload[1], ""));
|
||||
int curProduct = Convert.ToInt32(regex.Replace(payload[2], ""));
|
||||
int curDayKkal = Convert.ToInt32(regex.Replace(payload[3], ""));
|
||||
int curDay = (int)DateTime.Now.DayOfWeek;
|
||||
if (curDay == 0) curDay = 7;
|
||||
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
var cartObject = JsonConvert.DeserializeObject<CartObject>(user.cart);
|
||||
|
||||
var prodDb = db.ProductsDostavkas.Where(p =>
|
||||
p.id == curProduct &&
|
||||
JsonConvert.DeserializeObject<List<int>>(p.weekDays).Exists(e => e == curDay));
|
||||
products = prodDb.ToList().ConvertAll<ProductsDostavka>(el => new ProductsDostavka()
|
||||
{
|
||||
id = el.id,
|
||||
idIiko = el.idIiko,
|
||||
article = el.article,
|
||||
categoryId = el.categoryId,
|
||||
name = el.name,
|
||||
fullName = el.fullName,
|
||||
description = el.description,
|
||||
price = Convert.ToDouble( el.price),
|
||||
photo = el.photo,
|
||||
additions = JsonConvert.DeserializeObject<List<string>>(el.additions),
|
||||
recommends = JsonConvert.DeserializeObject<List<string>>(el.recommends),
|
||||
kkal = el.kkal,
|
||||
});
|
||||
|
||||
var orderPizza = new Order();
|
||||
var orderSous = new Order();
|
||||
if (cartObject.orders.Exists(o => o.id.Equals(curCategory + "-" + curProduct)))
|
||||
cartObject.orders.Find(o => o.id.Equals(curCategory + "-" + curProduct)).number++;
|
||||
else
|
||||
{
|
||||
var order = new Order()
|
||||
{
|
||||
id = curCategory + "-" + curProduct,
|
||||
idIiko = products[0].idIiko,
|
||||
fullname = products[0].fullName,
|
||||
name = products[0].name,
|
||||
price = products[0].price,
|
||||
number = 1,
|
||||
article = products[0].article,
|
||||
kkal = products[0].kkal,
|
||||
};
|
||||
cartObject.orders.Add(order);
|
||||
|
||||
}
|
||||
|
||||
user.cart = JsonConvert.SerializeObject(cartObject);
|
||||
db.SaveChanges();
|
||||
|
||||
foreach (var o in cartObject.orders)
|
||||
{
|
||||
sum += o.price * o.number;
|
||||
kkals += o.kkal * o.number;
|
||||
}
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton($"Завтрак (до {Math.Round(curDayKkal * 1.2 * 0.3)} ккал)", "selectPersonalMenu-1-" + curDayKkal, KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton($"Обед (до {Math.Round(curDayKkal * 1.2 * 0.4)} ккал)", "selectPersonalMenu-2-" + curDayKkal, KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton($"Перекус (до {Math.Round(curDayKkal * 1.2 * 0.1)} ккал)", "selectPersonalMenu-3-" + curDayKkal, KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton($"Ужин (до {Math.Round(curDayKkal * 1.2 * 0.3)} ккал)", "selectPersonalMenu-4-" + curDayKkal, KeyboardButtonColor.Primary)
|
||||
.AddLine();
|
||||
|
||||
if (cartObject.orders.Count > 0)
|
||||
{
|
||||
keyboardBuilder
|
||||
.AddButton("Личный кабинет", "startPL", KeyboardButtonColor.Default)
|
||||
.AddButton("Корзина: " + sum + " р", "selectCart-0", KeyboardButtonColor.Negative);
|
||||
}
|
||||
else
|
||||
{
|
||||
keyboardBuilder
|
||||
.AddButton("Личный кабинет", "startPL", KeyboardButtonColor.Default);
|
||||
}
|
||||
if (update.@object.client_info.carousel == true)
|
||||
{
|
||||
msg = "✅ " + products.Find(p => p.id == curProduct).fullName + " добавлен в корзину.";
|
||||
|
||||
}
|
||||
|
||||
//@params.Template = templateBuilder.Build();
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.Message = msg;
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
//else
|
||||
//{
|
||||
// switch (curCategory)
|
||||
// {
|
||||
// case 1:
|
||||
// if (update.@object.client_info.carousel == true)
|
||||
// showProductCaruselDouble.Execute(update, client, Con, curCategory, curProduct);
|
||||
// else
|
||||
// showProductDouble.Execute(update, client, Con, curCategory, curProduct, 2);
|
||||
// break;
|
||||
|
||||
// default:
|
||||
// if (update.@object.client_info.carousel == true)
|
||||
// showProductCaruselMain.Execute(update, client, Con, curCategory, curProduct, 1);
|
||||
// else
|
||||
// showProductMain.Execute(update, client, Con, curCategory, curProduct, 0, 2);
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в SelectAddToCartCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
49
SvetoforVKBot/Models/Commands/LK/Cart/SelectCartCommand.cs
Normal file
49
SvetoforVKBot/Models/Commands/LK/Cart/SelectCartCommand.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.RegularExpressions;
|
||||
using SvetoforVKBot.Models.Commands.LK.Cart;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Model;
|
||||
using VkNet.Model.RequestParams;
|
||||
using Newtonsoft.Json;
|
||||
using VkNet.Model.Keyboard;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Cart
|
||||
{
|
||||
public class SelectCartCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectCart-";
|
||||
|
||||
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;
|
||||
Regex regex = new Regex("[^0-9]");
|
||||
List<ProductsDostavka> products = new List<ProductsDostavka>();
|
||||
List<Button> buttons = new List<Button>();
|
||||
|
||||
try
|
||||
{
|
||||
string[] payload = update.@object.message.payload.Split('-');
|
||||
int curCart = Convert.ToInt32(regex.Replace(payload[1], ""));
|
||||
|
||||
ShowCart showCart = new ShowCart();
|
||||
showCart.Execute(update, client, db, curCart);
|
||||
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в SelectCartCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using SvetoforVKBot.Models.Commands.LK.Menu.Products;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Model.RequestParams;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using Newtonsoft.Json;
|
||||
using System.Linq;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Cart
|
||||
{
|
||||
public class SelectConfirmClearCartCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectConfirmClearCart\"}";
|
||||
|
||||
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;
|
||||
string msg = "";
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
|
||||
try
|
||||
{
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
var jsCart = JsonConvert.DeserializeObject<CartObject>(user.cart);
|
||||
jsCart.orders.RemoveAll(o => o.id.StartsWith("0-") == false);
|
||||
user.cart = JsonConvert.SerializeObject(jsCart);
|
||||
db.SaveChanges();
|
||||
|
||||
msg = "✅Корзина очищена.\nВозвращаю в Личный кабинет.\n";
|
||||
|
||||
ShowLKCommand showLK = new ShowLKCommand();
|
||||
showLK.Execute(update, client, db);
|
||||
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в SelectConfirmClearCartCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.RegularExpressions;
|
||||
using Newtonsoft.Json;
|
||||
using SvetoforVKBot.Models.Commands.LK.Cart;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Model.RequestParams;
|
||||
using SvetoforVKBot.Models.Commands.LK.Menu.Products;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using System.Linq;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Cart
|
||||
{
|
||||
public class SelectEditCartCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectEditCart-";
|
||||
|
||||
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;
|
||||
Regex regex = new Regex("[^0-9]");
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
string msg = "";
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
string[] payload = update.@object.message.payload.Split('-');
|
||||
int action = Convert.ToInt32(regex.Replace(payload[1], ""));
|
||||
int curCart = Convert.ToInt32(regex.Replace(payload[2], ""));
|
||||
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
var cartObject = JsonConvert.DeserializeObject<CartObject>(user.cart);
|
||||
|
||||
|
||||
if (cartObject.orders[curCart].id.StartsWith("0-")) return;
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case 1: // -
|
||||
if (cartObject.orders[curCart].number == 1)
|
||||
cartObject.orders.RemoveAt(curCart);
|
||||
else
|
||||
cartObject.orders[curCart].number--;
|
||||
break;
|
||||
case 2: // +
|
||||
cartObject.orders[curCart].number++;
|
||||
break;
|
||||
};
|
||||
|
||||
if (action > 2)
|
||||
{
|
||||
int count = action - 3;
|
||||
if (count == 0)
|
||||
cartObject.orders.RemoveAt(curCart);
|
||||
else
|
||||
cartObject.orders[curCart].number = count;
|
||||
}
|
||||
|
||||
user.cart = JsonConvert.SerializeObject(cartObject);
|
||||
db.SaveChanges();
|
||||
|
||||
if (cartObject.orders.Count > 0)
|
||||
{
|
||||
if (curCart >= cartObject.orders.Count)
|
||||
curCart = cartObject.orders.Count - 1;
|
||||
ShowCart showCart = new ShowCart();
|
||||
showCart.Execute(update, client, db, curCart);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = "Корзина оказалась пустой. \n" +
|
||||
"\n" +
|
||||
"Возвращаю в Личный кабинет";
|
||||
ShowLKCommand showLK = new ShowLKCommand();
|
||||
showLK.Execute(update, client, db);
|
||||
}
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в SelectEditCartCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
192
SvetoforVKBot/Models/Commands/LK/Cart/ShowCart.cs
Normal file
192
SvetoforVKBot/Models/Commands/LK/Cart/ShowCart.cs
Normal file
@@ -0,0 +1,192 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using Newtonsoft.Json;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.LK.Cart
|
||||
{
|
||||
public class ShowCart
|
||||
{
|
||||
public void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db, int curCart) //curCart - порядковый номер в массиве корзины
|
||||
{
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
int cartCount = 0;
|
||||
var chatId = update.@object.message.from_id;
|
||||
string msg = "";
|
||||
//string voronka = "";
|
||||
List<CategoriesDostavka> categories = new List<CategoriesDostavka>();
|
||||
List<ProductsDostavka> products = new List<ProductsDostavka>();
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int prevCart = 0, nextCart = 0;
|
||||
double sum = 0;
|
||||
double fullSum = 0;
|
||||
string label = "";
|
||||
var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
int kkals = 0;
|
||||
try
|
||||
{
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
var cartObject = JsonConvert.DeserializeObject<CartObject>(user.cart);
|
||||
|
||||
|
||||
//SqlCommand getCart = new SqlCommand("SELECT cart, voronka FROM Users WHERE chatId = @chatId;", Con);
|
||||
//getCart.Parameters.AddWithValue("@chatId", chatId);
|
||||
//SqlDataReader rgetCart = getCart.ExecuteReader();
|
||||
//rgetCart.Read();
|
||||
//var cartObject = JsonConvert.DeserializeObject<CartObject>(rgetCart["cart"].ToString());
|
||||
//voronka = rgetCart["voronka"].ToString();
|
||||
//rgetCart.Close();
|
||||
|
||||
//cartObject.orders.RemoveAll(o => o.article.StartsWith("00-"));
|
||||
cartObject.dostavkaCost = 100;
|
||||
|
||||
//if (cartObject.orders.Count == 0)
|
||||
//{
|
||||
// msg = "Корзина пуста.\n📋Возвращаю в основное меню";
|
||||
// ShowMenuDostavka showMenuDostavka = new ShowMenuDostavka();
|
||||
// showMenuDostavka.Execute(update, client, Con, msg, 1, 0);
|
||||
// return;
|
||||
//}
|
||||
|
||||
if (curCart >= cartObject.orders.Count)
|
||||
{
|
||||
curCart = cartObject.orders.Count - 1;
|
||||
prevCart = curCart - 1;
|
||||
nextCart = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
prevCart = curCart - 1;
|
||||
nextCart = curCart + 1;
|
||||
}
|
||||
if ((curCart + 1) == cartObject.orders.Count)
|
||||
{
|
||||
prevCart = curCart - 1;
|
||||
nextCart = 0;
|
||||
}
|
||||
if (curCart == 0)
|
||||
{
|
||||
prevCart = cartObject.orders.Count - 1;
|
||||
nextCart = curCart + 1;
|
||||
}
|
||||
string promo = "";
|
||||
msg = "Ваша корзина: \n";
|
||||
|
||||
double sumCheck = 0;
|
||||
foreach (var o in cartObject.orders)
|
||||
{
|
||||
sumCheck += o.price * o.number;
|
||||
}
|
||||
|
||||
for (i = 0; i < cartObject.orders.Count; i++)
|
||||
{
|
||||
cartCount++;
|
||||
switch (cartObject.orders[i].id)
|
||||
{
|
||||
|
||||
default:
|
||||
msg += (i + 1).ToString() + ". " +
|
||||
cartObject.orders[i].fullname + " - " + cartObject.orders[i].kkal + " ккал. " +
|
||||
cartObject.orders[i].number + " шт. " +
|
||||
(cartObject.orders[i].price * cartObject.orders[i].number).ToString() + " ₽ \n";
|
||||
sum += cartObject.orders[i].price * cartObject.orders[i].number;
|
||||
kkals += cartObject.orders[i].kkal * cartObject.orders[i].number;
|
||||
break;
|
||||
}
|
||||
//msg += (i + 1).ToString() + ". " +
|
||||
// cartObject.orders[i].fullname + " - " +
|
||||
// cartObject.orders[i].number + " шт. " +
|
||||
// (cartObject.orders[i].price * cartObject.orders[i].number).ToString() + " ₽ \n";
|
||||
|
||||
|
||||
/*cartCount++;
|
||||
for (j = 0; j < cartObject.orders.Count; j++)
|
||||
{
|
||||
msg += " " + cartCount.ToString() + "." + (j + 1).ToString() + " Доп - " +
|
||||
cartObject.orders[i].addition[j].fullname + " - " +
|
||||
cartObject.orders[i].addition[j].number + " шт. " +
|
||||
(cartObject.orders[i].addition[j].price * cartObject.orders[i].addition[j].number).ToString() + " ₽ \n";
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
fullSum = sum;
|
||||
|
||||
user.cart = JsonConvert.SerializeObject(cartObject);
|
||||
db.SaveChanges();
|
||||
|
||||
//SqlCommand updCart = new SqlCommand("UPDATE Users SET cart = @cart WHERE chatId = @chatId;", Con);
|
||||
//updCart.Parameters.AddWithValue("@chatId", chatId);
|
||||
//updCart.Parameters.AddWithValue("@cart", JsonConvert.SerializeObject(cartObject));
|
||||
//updCart.ExecuteNonQuery();
|
||||
|
||||
msg += "\n" +
|
||||
"Итого: " + fullSum + " ₽ | " + kkals + " ккал.";
|
||||
|
||||
label = cartObject.orders[curCart].name + " " +
|
||||
cartObject.orders[curCart].price + " ₽ * " +
|
||||
cartObject.orders[curCart].number + " = " +
|
||||
(cartObject.orders[curCart].price * cartObject.orders[curCart].number).ToString() + " ₽";
|
||||
|
||||
if (label.Length > 40)
|
||||
label = cartObject.orders[curCart].name + " " +
|
||||
(cartObject.orders[curCart].price * cartObject.orders[curCart].number).ToString() + " ₽";
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton(label, "selectCart-" + curCart, KeyboardButtonColor.Default)
|
||||
.AddLine()
|
||||
.AddButton("-", "selectEditCart-1-" + curCart, KeyboardButtonColor.Default)
|
||||
.AddButton(cartObject.orders[curCart].number + " шт", "selectCartCount-" + curCart, KeyboardButtonColor.Default)
|
||||
.AddButton("+", "selectEditCart-2-" + curCart, KeyboardButtonColor.Default)
|
||||
.AddButton("🗑Очистить", "selectConfirmClearCart", KeyboardButtonColor.Default)
|
||||
.AddLine()
|
||||
.AddButton("<<", "selectCart-" + prevCart, KeyboardButtonColor.Primary)
|
||||
.AddButton((curCart + 1).ToString() + "/" + cartObject.orders.Count, "selectCart-" + curCart, KeyboardButtonColor.Default)
|
||||
.AddButton(">>", "selectCart-" + nextCart, KeyboardButtonColor.Primary);
|
||||
|
||||
keyboardBuilder
|
||||
.AddLine()
|
||||
.AddButton("Личный кабинет", "startPL", KeyboardButtonColor.Default);
|
||||
|
||||
|
||||
@params.Message = msg;
|
||||
@params.UserId = chatId;
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.DontParseLinks = true;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в ShowCart: " + 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();
|
||||
private int GetRandomId()
|
||||
{
|
||||
|
||||
var intBytes = new byte[4];
|
||||
|
||||
Rng.GetBytes(intBytes);
|
||||
|
||||
return BitConverter.ToInt32(intBytes, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user