GetListInfo.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using Microsoft.AspNetCore.Mvc;
  2. using Microsoft.Data.SqlClient;
  3. namespace WebApplication1
  4. {
  5. public class GetListInfo
  6. {
  7. public static List<string> GetRegion()
  8. {
  9. Connecthion.SqlConnection.Open();
  10. SqlCommand sqlCommand = new SqlCommand("select NameRegion from Region", Connecthion.SqlConnection);
  11. List<string> list = new List<string>();
  12. SqlDataReader reader = sqlCommand.ExecuteReader();
  13. while (reader.Read())
  14. {
  15. list.Add(reader.GetString(0));
  16. }
  17. Connecthion.SqlConnection.Close();
  18. reader.Close();
  19. return list;
  20. }
  21. public static List<string> GetReciplentMessage()
  22. {
  23. Connecthion.SqlConnection.Open();
  24. SqlCommand sqlCommand = new SqlCommand("select RecipientMessage from RecipientMessage", Connecthion.SqlConnection);
  25. List<string> list = new List<string>();
  26. SqlDataReader reader = sqlCommand.ExecuteReader();
  27. while (reader.Read())
  28. {
  29. list.Add(reader.GetString(0));
  30. }
  31. Connecthion.SqlConnection.Close();
  32. reader.Close();
  33. return list;
  34. }
  35. [HttpPost]
  36. public void MyAction(string action)
  37. {
  38. Console.WriteLine("Негры");
  39. }
  40. }
  41. }