private async static void SendDeskrip(Message m, GroupDish group) { DB.OpenAsync(); while (DB.GetConnection().State == ConnectionState.Executing) { ; } SqlCommand command; if (group == GroupDish.Pizza) { command = new SqlCommand("SELECT * FROM[Dishes] WHERE type = 'Pizza'", DB.GetConnection()); } else if (group == GroupDish.Drinks) { command = new SqlCommand("SELECT * FROM[Dishes] WHERE type = 'Drinks'", DB.GetConnection()); } else { command = new SqlCommand("SELECT * FROM[Dishes] WHERE type = 'Other'", DB.GetConnection()); } try { SqlDataReader reader = command.ExecuteReader(); int counter = 0; while (await reader.ReadAsync()) { counter++; if (reader["LinkIMG"].ToString() == "") { string text = String.Format($"{counter}. {reader["Name"]} \n Ціна: {reader["prise"]} грн \n {reader["Deskription"]}"); Send(text, m.Chat.Id); } else { try { string text = String.Format($"{counter}. {reader["Name"]} \n Ціна: {reader["prise"]} грн \n {reader["Deskription"]}"); SendPhoto(reader["LinkIMG"].ToString(), m.Chat.Id, text); } catch { Console.WriteLine("Wrong link"); } } } reader.Close(); } catch (Exception e) { Console.WriteLine(e.ToString()); } DB.Close(); }
private async static void SendPropoz(GroupDish group, Message m) { DB.OpenAsync(); SqlCommand command; if (group == GroupDish.Pizza) { command = new SqlCommand("SELECT * FROM[Dishes] WHERE type = 'Pizza'", DB.GetConnection()); } else if (group == GroupDish.Drinks) { command = new SqlCommand("SELECT * FROM[Dishes] WHERE type = 'Drinks'", DB.GetConnection()); } else { command = new SqlCommand("SELECT * FROM[Dishes] WHERE type = 'Other'", DB.GetConnection()); } try { SqlDataReader reader = await command.ExecuteReaderAsync(); int counter = 0; while (await reader.ReadAsync()) { counter++; if (reader["LinkIMG"].ToString() == "") { string text = String.Format($"{counter}. {reader["Name"]} \n Ціна: {reader["prise"]} грн \n {reader["Deskription"]}"); Send(text, m.Chat.Id, Menu.AddToAhopCart(int.Parse(reader["id"].ToString()))); } else { try { string text = String.Format($"{counter}. {reader["Name"]} \n Ціна: {reader["prise"]} грн \n {reader["Deskription"]}"); SendPhoto(reader["LinkIMG"].ToString(), m.Chat.Id, text, Menu.AddToAhopCart(int.Parse(reader["id"].ToString()))); } catch { Console.WriteLine("Wrong link"); } } } Send("Вибирайте те що до смаку)", m.Chat.Id, Menu.Order(Users[m.Chat.Id].order.Count + Users[m.Chat.Id].orderCreatePizza.Count)); Users[m.Chat.Id].Status = UserStat.EditOrder; reader.Close(); } catch (Exception e) { Console.WriteLine(e.ToString()); } DB.Close(); }