RentProperty.xaml.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Shapes;
  14. namespace Agency.Windows
  15. {
  16. /// <summary>
  17. /// Логика взаимодействия для RentProperty.xaml
  18. /// </summary>
  19. public partial class RentProperty : Window
  20. {
  21. public RentProperty()
  22. {
  23. InitializeComponent();
  24. gr606_midvlContext context = new gr606_midvlContext();
  25. var address = context.Addreses;
  26. var property = context.TheProperties;
  27. foreach (var item in address)
  28. {
  29. if (CityRent.Items.Contains(item.City)) { }
  30. else
  31. {
  32. CityRent.Items.Add(item.City);
  33. }
  34. }
  35. foreach (var prpIt in property)
  36. {
  37. if (TypeProperty.Items.Contains(prpIt.PropertyType)) { }
  38. else
  39. {
  40. TypeProperty.Items.Add(prpIt.PropertyType);
  41. }
  42. if (RayonProperty.Items.Contains(prpIt.District)) { }
  43. else
  44. {
  45. RayonProperty.Items.Add(prpIt.District);
  46. }
  47. }
  48. }
  49. private void Search(object sender, RoutedEventArgs e)
  50. {
  51. try
  52. {
  53. ListProperty.Items.Clear();
  54. gr606_midvlContext context = new gr606_midvlContext();
  55. var items = context.TheProperties.Where(x => x.TypeRent == "Сдаётся" && x.Price <= Convert.ToInt32(BorderPrice.Text)
  56. && x.PropertyType == TypeProperty.Text && x.District == RayonProperty.Text);
  57. var adreses = context.Addreses;
  58. //string[] itemsList;
  59. string post;
  60. foreach (var item in items)
  61. {
  62. //var adr = adreses.SingleOrDefault(x => x.Id == item.Address);
  63. post = $"Описание: {item.Name}\n" +
  64. $"Стоимость: {item.Price}р\n" +
  65. $"Район: {item.District}\n" +
  66. $"Тип нидвижимости: {item.PropertyType}\n" +
  67. $"Этаж: {item.Floor}\n" +
  68. $"Кол-во комнат: {item.Rooms}\n" +
  69. $"Плащадь: {item.Area} м2\n" +
  70. $"*************************************\n" +
  71. $"Если заинтересовала недвижимость то обезательно\n" +
  72. $"Звоните в Агенство! Номер этой недвижимости: ({item.Id})\n" +
  73. $"Номер Агенства: (Тут уже будет номер)\n" +
  74. $"*************************************";
  75. ListProperty.Items.Add(post);
  76. }
  77. if (ListProperty.Items.Count == 0)
  78. {
  79. ListProperty.Items.Add("Увы по вашим критериям недвижимости нет!");
  80. }
  81. }
  82. catch (Exception)
  83. {
  84. ListProperty.Items.Add("Увы по вашим критериям недвижимости нет!");
  85. }
  86. }
  87. void ListProperty_Click(object sender, EventArgs e)
  88. {
  89. MessageBox.Show(ListProperty.SelectedItem.ToString());
  90. }
  91. private void Close(object sender, RoutedEventArgs e)
  92. {
  93. Windows.HomeWindow home = new Windows.HomeWindow();
  94. home.Show();
  95. this.Hide();
  96. }
  97. }
  98. }