ПрытовИЕ 8 miesięcy temu
rodzic
commit
41a1febd27
31 zmienionych plików z 162 dodań i 12 usunięć
  1. BIN
      UPtur/Assets/Pictures/pic.png
  2. BIN
      UPtur/Assets/Pictures/Болгарское наследие.jpg
  3. BIN
      UPtur/Assets/Pictures/Волшебный Восток.jpg
  4. BIN
      UPtur/Assets/Pictures/Город с большими амбициями.jpg
  5. BIN
      UPtur/Assets/Pictures/Город четырех ворот.jpg
  6. BIN
      UPtur/Assets/Pictures/Древний Минск.jpg
  7. BIN
      UPtur/Assets/Pictures/Жемчужина Татарстана.jpg
  8. BIN
      UPtur/Assets/Pictures/Знакомьтесь, Амстердам!.jpg
  9. BIN
      UPtur/Assets/Pictures/Из Алании к загадочным пещерам Алтынбешик.jpg
  10. BIN
      UPtur/Assets/Pictures/Многоликий Сувон.jpg
  11. BIN
      UPtur/Assets/Pictures/Москва поэтическая.jpg
  12. BIN
      UPtur/Assets/Pictures/Незабываемый Дели.jpg
  13. BIN
      UPtur/Assets/Pictures/По старому Таллину.jpg
  14. BIN
      UPtur/Assets/Pictures/Романтика белых ночей и разводных мостов.jpg
  15. BIN
      UPtur/Assets/Pictures/Свидание с Хельсинки.jpg
  16. BIN
      UPtur/Assets/Pictures/Сердце Ирана.jpg
  17. BIN
      UPtur/Assets/Pictures/Сердце Северной Карелии.jpg
  18. BIN
      UPtur/Assets/Pictures/Старый город.jpg
  19. BIN
      UPtur/Assets/Pictures/Столица страны Утренней Свежести.jpg
  20. BIN
      UPtur/Assets/Pictures/Страна идеальной гармонии.jpg
  21. BIN
      UPtur/Assets/Pictures/Урбанистическая Бразилия.jpg
  22. BIN
      UPtur/Assets/Pictures/Финская крепость.jpg
  23. BIN
      UPtur/Assets/Pictures/Финский романтизм.jpg
  24. BIN
      UPtur/Assets/logo.jpeg
  25. 2 0
      UPtur/Models/Tour.cs
  26. 4 0
      UPtur/UPtur.csproj
  27. 5 0
      UPtur/ViewModels/MainWindowViewModel.cs
  28. 132 5
      UPtur/ViewModels/ToursViewModel.cs
  29. 3 1
      UPtur/Views/MainWindow.axaml
  30. 3 1
      UPtur/Views/PageNavigate.axaml
  31. 13 5
      UPtur/Views/Tours.axaml

BIN
UPtur/Assets/Pictures/pic.png


BIN
UPtur/Assets/Pictures/Болгарское наследие.jpg


BIN
UPtur/Assets/Pictures/Волшебный Восток.jpg


BIN
UPtur/Assets/Pictures/Город с большими амбициями.jpg


BIN
UPtur/Assets/Pictures/Город четырех ворот.jpg


BIN
UPtur/Assets/Pictures/Древний Минск.jpg


BIN
UPtur/Assets/Pictures/Жемчужина Татарстана.jpg


BIN
UPtur/Assets/Pictures/Знакомьтесь, Амстердам!.jpg


BIN
UPtur/Assets/Pictures/Из Алании к загадочным пещерам Алтынбешик.jpg


BIN
UPtur/Assets/Pictures/Многоликий Сувон.jpg


BIN
UPtur/Assets/Pictures/Москва поэтическая.jpg


BIN
UPtur/Assets/Pictures/Незабываемый Дели.jpg


BIN
UPtur/Assets/Pictures/По старому Таллину.jpg


BIN
UPtur/Assets/Pictures/Романтика белых ночей и разводных мостов.jpg


BIN
UPtur/Assets/Pictures/Свидание с Хельсинки.jpg


BIN
UPtur/Assets/Pictures/Сердце Ирана.jpg


BIN
UPtur/Assets/Pictures/Сердце Северной Карелии.jpg


BIN
UPtur/Assets/Pictures/Старый город.jpg


BIN
UPtur/Assets/Pictures/Столица страны Утренней Свежести.jpg


BIN
UPtur/Assets/Pictures/Страна идеальной гармонии.jpg


BIN
UPtur/Assets/Pictures/Урбанистическая Бразилия.jpg


BIN
UPtur/Assets/Pictures/Финская крепость.jpg


BIN
UPtur/Assets/Pictures/Финский романтизм.jpg


BIN
UPtur/Assets/logo.jpeg


+ 2 - 0
UPtur/Models/Tour.cs

@@ -19,8 +19,10 @@ public partial class Tour
     public decimal Price { get; set; }
 
     public BitArray IsActual { get; set; } = null!;
+    public string DescriptionWithoutNull => (Desription == null) ? string.Empty : Desription;
 
     public virtual ICollection<HotelOfTour> HotelOfTours { get; set; } = new List<HotelOfTour>();
 
     public virtual ICollection<TypeOfTour> TypeOfTours { get; set; } = new List<TypeOfTour>();
 }
+

+ 4 - 0
UPtur/UPtur.csproj

@@ -12,6 +12,10 @@
     <AvaloniaResource Include="Assets\**" />
   </ItemGroup>
 
+  <ItemGroup>
+    <None Remove="Assets\logo.jpeg" />
+  </ItemGroup>
+
 
   <ItemGroup>
     <PackageReference Include="Avalonia" Version="11.0.10" />

+ 5 - 0
UPtur/ViewModels/MainWindowViewModel.cs

@@ -35,6 +35,11 @@ namespace UPtur.ViewModels
             set => tvm = value;
         }
 
+        public void Navigate()
+        {
+            US = new Views.PageNavigate();
+        }
+
     }
 
     

+ 132 - 5
UPtur/ViewModels/ToursViewModel.cs

@@ -9,11 +9,21 @@ namespace UPtur.ViewModels
 	public class ToursViewModel : ReactiveObject
 	{
         UpPrytovContext DB = new UpPrytovContext();
-        private List<Tour>? _tours;
+       private List<Tour>? _tours;
         public List<Tour>? Tours { get => _tours; set => this.RaiseAndSetIfChanged(ref _tours, value); }
 
-        private List<string>? _types;
-        public List<string>? Types { get => _types; set => this.RaiseAndSetIfChanged(ref _types, value); }
+        private static List<string>? _types;
+        public static List<string>? Types { get => _types; set => _types = value; }
+
+        private static List<string>? _sort;
+        public static List<string>? Sort { get => _sort; set => _sort = value; }
+
+        private decimal _priceOfAll;
+        public decimal PriceOfAll
+        {
+            get => _priceOfAll; 
+            set => this.RaiseAndSetIfChanged(ref _priceOfAll, value);
+        }
 
         private bool _checkOrNot = false;
         public bool CheckOrNot
@@ -37,16 +47,133 @@ namespace UPtur.ViewModels
             }
         }
 
+        private string? _selectedItem;
+        public string? SelectedItem
+        {
+            get
+            {
+                return _selectedItem;
+            }
+            set
+            {
+                _selectedItem = value;
+                Filter();
+            }
+        }
+
+        private string? _selectedSort;
+        public string? SelectedSort
+        {
+            get
+            {
+                return _selectedSort;
+            }
+            set
+            {
+                _selectedSort = value;
+                Filter();
+            }
+        }
+
         public ToursViewModel()
         {
             Tours = DB.Tours.ToList();
-            Types = DB.Types.Select(x => x.Name).ToList();
+            Types = DB.Types.Select(x=>x.Name).ToList();
             Types.Insert(0, "Âñå");
+            SelectedItem = Types[0];
+            Sort = new List<string> { "Áåç ñîðòèðîâêè", "Ïî âîçðàñòàíèþ öåíû", "Ïî óáûâàíèþ öåíû" };
+            SelectedSort = Sort[0];
         }
 
         public void Filter()
         {
+            Tours = DB.Tours.ToList();
+            PriceOfAll = 0;
+
+            if (SelectedItem != "Âñå")
+            {
+                List <TypeOfTour> TypesForFilter = DB.TypeOfTours.ToList();
+                List <int> IdForFilter = new List<int>();
+                switch (SelectedItem)
+                {
+                    case "Ìåæäóíàðîäíûé òóðèçì":
+                        TypesForFilter = TypesForFilter.Where(x=>x.TypeId==1).ToList();
+                        IdForFilter = TypesForFilter.Select(x=>x.TourId).ToList();
+                        Tours = Tours.Where(x=> IdForFilter.Contains(x.Id)).ToList();
+                        break;
+                    case "Âíóòðåííèé òóðèçì":
+                        TypesForFilter = TypesForFilter.Where(x => x.TypeId == 2).ToList();
+                        IdForFilter = TypesForFilter.Select(x => x.TourId).ToList();
+                        Tours = Tours.Where(x => IdForFilter.Contains(x.Id)).ToList();
+                        break;
+                    case "Ëå÷åáíî-îçäîðîâèòåëüíûå òóðû":
+                        TypesForFilter = TypesForFilter.Where(x => x.TypeId == 3).ToList();
+                        IdForFilter = TypesForFilter.Select(x => x.TourId).ToList();
+                        Tours = Tours.Where(x => IdForFilter.Contains(x.Id)).ToList();
+                        break;
+                    case "Ïëÿæíûå òóðû":
+                        TypesForFilter = TypesForFilter.Where(x => x.TypeId == 4).ToList();
+                        IdForFilter = TypesForFilter.Select(x => x.TourId).ToList();
+                        Tours = Tours.Where(x => IdForFilter.Contains(x.Id)).ToList();
+                        break;
+                    case "Ýêñêóðñèîííûå òóðû":
+                        TypesForFilter = TypesForFilter.Where(x => x.TypeId == 5).ToList();
+                        IdForFilter = TypesForFilter.Select(x => x.TourId).ToList();
+                        Tours = Tours.Where(x => IdForFilter.Contains(x.Id)).ToList();
+                        break;
+                    case "Ñïåöèàëèçèðîâàííûå äåòñêèå òóðû":
+                        TypesForFilter = TypesForFilter.Where(x => x.TypeId == 6).ToList();
+                        IdForFilter = TypesForFilter.Select(x => x.TourId).ToList();
+                        Tours = Tours.Where(x => IdForFilter.Contains(x.Id)).ToList();
+                        break;
+                    case "Îáñëóæèâàíèå êîðïîðàòèâíûõ êëèåíòîâ ïî çàêàçó":
+                        TypesForFilter = TypesForFilter.Where(x => x.TypeId == 7).ToList();
+                        IdForFilter = TypesForFilter.Select(x => x.TourId).ToList();
+                        Tours = Tours.Where(x => IdForFilter.Contains(x.Id)).ToList();
+                        break;
+                    case "Ãîðíîëûæíûå êóðîðòû":
+                        TypesForFilter = TypesForFilter.Where(x => x.TypeId == 8).ToList();
+                        IdForFilter = TypesForFilter.Select(x => x.TourId).ToList();
+                        Tours = Tours.Where(x => IdForFilter.Contains(x.Id)).ToList();
+                        break;
+                    case "Êóëüòóðíî-èñòîðè÷åñêèå òóðû":
+                        TypesForFilter = TypesForFilter.Where(x => x.TypeId == 9).ToList();
+                        IdForFilter = TypesForFilter.Select(x => x.TourId).ToList();
+                        Tours = Tours.Where(x => IdForFilter.Contains(x.Id)).ToList();
+                        break;
+                    default:
+                        break;
+                }
+            }
+
+            if(CheckOrNot)
+            {
+                Tours = Tours.Where(x => x.IsActual[0]==true).ToList();
+            }
 
+            if(FindTour!=null && FindTour != "")
+            {
+                Tours = Tours.Where(x=>x.Name.ToUpper().Contains(FindTour.ToString().ToUpper()) || x.DescriptionWithoutNull.Contains(FindTour.ToString().ToUpper())).ToList();
+            }
+
+            if(SelectedSort != "Áåç ñîðòèðîâêè")
+            {
+                switch(SelectedSort)
+                {
+                    case "Ïî âîçðàñòàíèþ öåíû":
+                        Tours = Tours.OrderBy(x=>x.Price).ToList();
+                        break;
+                    case "Ïî óáûâàíèþ öåíû":
+                        Tours = Tours.OrderByDescending(x => x.Price).ToList();
+                        break;
+                }
+            }
+
+            foreach(Tour t in Tours)
+            {
+                PriceOfAll += (t.Price * t.TicketCount);
+            }
         }
     }
-}
+
+}

+ 3 - 1
UPtur/Views/MainWindow.axaml

@@ -6,7 +6,9 @@
         mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
         x:Class="UPtur.Views.MainWindow"
         x:DataType="vm:MainWindowViewModel"
-        Icon="/Assets/avalonia-logo.ico"
+        Icon="/Assets/logo.jpeg"
+		Background="#bae3e8"
+		FontFamily="Comic Sans MS"
         Title="UPtur">
 
     <Design.DataContext>

+ 3 - 1
UPtur/Views/PageNavigate.axaml

@@ -6,9 +6,11 @@
 			 xmlns:vm="using:UPtur.ViewModels"
 			 x:DataType="vm:MainWindowViewModel"
              x:Class="UPtur.Views.PageNavigate">
-	<Grid Background="">
+	<Grid >
 
 		<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"  >
+			
+			
 			<TextBlock FontSize="20" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,0,40" > Путешествуй по России </TextBlock>
 			<Button Background="" Command="{Binding ChangePageToTours}" HorizontalContentAlignment="Center" Content="Просмотр Туров" Width="250" Height="32" >  </Button>
 			<Button Background="" Command="{Binding ChangePageToHotels}" HorizontalContentAlignment="Center" Margin="0,20,0,0" Content="Просмотр Отелей" Width="250" Height="32" > </Button>

+ 13 - 5
UPtur/Views/Tours.axaml

@@ -6,9 +6,9 @@
              x:Class="UPtur.Views.Tours"
 			 xmlns:vm="using:UPtur.ViewModels"
 			 x:DataType="vm:MainWindowViewModel"
-			 FontFamily="{StaticResource Comic}">
+			 FontFamily="Comic Sans MS">
 
-	<Grid RowDefinitions="*,2.0*">
+	<Grid Background="#bae3e8" RowDefinitions="*,2.0*">
 		<StackPanel Margin="0,10,0,10" Orientation="Vertical" HorizontalAlignment="Center" >
 			<StackPanel Orientation="Vertical" VerticalAlignment="Center">
 				<TextBlock Text="Введите текст для поиска: "/>
@@ -18,10 +18,14 @@
 				<TextBlock Margin="0,0,0,0" Text="Выберите тип: "/>
 				<ComboBox SelectedIndex="0" ItemsSource="{Binding ToursVM.Types}" Width="300"/>
 			</StackPanel>
+			<StackPanel HorizontalAlignment="Center" Margin="0,10,0,0" Orientation="Vertical" VerticalAlignment="Center">
+				<TextBlock VerticalAlignment="Center" Text="Выберите сортировку: "/>
+				<ComboBox SelectedIndex="0" SelectedItem="{Binding ToursVM.SelectedSort}" ItemsSource="{Binding ToursVM.Sort}" Width="300"/>
+			</StackPanel>
 			<CheckBox IsChecked="{Binding ToursVM.CheckOrNot}" HorizontalAlignment="Left" Content="Только актуальные туры"/>
 		</StackPanel>
 
-		<ListBox ItemsSource="{Binding ToursVM.Tours}" Grid.Row="1">
+		<ListBox Background="#bae3e8" ItemsSource="{Binding ToursVM.Tours}" Grid.Row="1">
 			<ListBox.ItemsPanel>
 				<ItemsPanelTemplate>
 					<WrapPanel Orientation="Horizontal" HorizontalAlignment="Center"/>
@@ -32,11 +36,11 @@
 					<Border Width="300" Height="270" BorderBrush="Black" BorderThickness="1" Padding="5">
 						<StackPanel Orientation="Vertical" VerticalAlignment="Center">
 							<TextBlock Margin="0 0 0 5" TextWrapping="Wrap" FontSize="19" TextAlignment="Center" HorizontalAlignment="Center" Text="{Binding Name}"></TextBlock>
-							<Image Margin="5" Source="avares://TravelAgency/Assets/picture.png" Width="270" Height="120"></Image>
+							<Image Margin="5" Source="avares://UPtur/Assets/Pictures/pic.png" Width="270" Height="120"></Image>
 							<TextBlock Margin="5" FontSize="20" FontWeight="ExtraBold" HorizontalAlignment="Center" TextAlignment="Center" Text="{Binding StringFormat={}{0:#} РУБ, Path=Price}"></TextBlock>
 							<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
 								<StackPanel HorizontalAlignment="Left" Margin="0 0 25 0">
-									<TextBlock FontSize="16" Text="{Binding GetActual}"></TextBlock>
+									
 								</StackPanel>
 								<StackPanel HorizontalAlignment="Right" Margin="25 0 0 0">
 									<TextBlock FontSize="16" Text="{Binding StringFormat=Билетов: {0:#}, Path=TicketCount}"></TextBlock>
@@ -48,5 +52,9 @@
 				</DataTemplate>
 			</ListBox.ItemTemplate>
 		</ListBox>
+		<StackPanel  VerticalAlignment="Top" Margin="10,26,10,10">
+			<Button Background="#445c93" Width="120" Height="35" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Command="{Binding Navigate}" Content="Назад"/>
+		</StackPanel>
 	</Grid>
+	
 </UserControl>