mirror of
https://github.com/lucaspalomodevelop/ferienhaus.git
synced 2026-03-12 23:27:23 +00:00
Merge branch 'v2'
This commit is contained in:
commit
152f78825b
@ -5,25 +5,39 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:ferienhaus"
|
||||
mc:Ignorable="d"
|
||||
Title="AdminView" Height="450" Width="800">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="90*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
Title="AdminView" Height="379" Width="381">
|
||||
<Grid HorizontalAlignment="Left" Height="469" Margin="0,0,-8,-11" VerticalAlignment="Top" Width="400">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="09*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="371*"/>
|
||||
<RowDefinition Height="125*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="1" Grid.Column="1" DataContext="{Binding ElementName=UI}">
|
||||
<TextBox Height="23" HorizontalAlignment="Left" Name="textBox1" VerticalAlignment="Top" Width="120" />
|
||||
<Button Height="23" HorizontalAlignment="Left" Name="Serach" VerticalAlignment="Top" Width="120" >Seach</Button>
|
||||
<DataGrid x:Name="grid" >
|
||||
|
||||
</DataGrid>
|
||||
</StackPanel>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="297*"/>
|
||||
<ColumnDefinition Width="103*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
|
||||
<!--Auf felder zugreifen (by x:name) :-->
|
||||
<!--TextBox ortschaft = (TextBox) this.FindName("ortschaft");-->
|
||||
|
||||
<Rectangle Fill="#575757" HorizontalAlignment="Left" Height="51" Stroke="Black" VerticalAlignment="Top" Width="375" Margin="0,46,0,0" Grid.ColumnSpan="2"/>
|
||||
<Rectangle Fill="#2e2e2e" HorizontalAlignment="Left" Height="50" Margin="0,97,0,0" Stroke="Black" VerticalAlignment="Top" Width="375" Grid.ColumnSpan="2"/>
|
||||
<Rectangle Fill="#575757" HorizontalAlignment="Left" Height="51" Margin="0,146,0,0" Stroke="Black" VerticalAlignment="Top" Width="375" Grid.ColumnSpan="2"/>
|
||||
<Rectangle Fill="#2e2e2e" HorizontalAlignment="Left" Height="51" Margin="0,197,0,0" Stroke="Black" VerticalAlignment="Top" Width="375" Grid.ColumnSpan="2"/>
|
||||
<Rectangle Fill="#575757" HorizontalAlignment="Left" Height="102" Margin="0,248,0,0" Stroke="Black" VerticalAlignment="Top" Width="375" Grid.ColumnSpan="2"/>
|
||||
<Rectangle Fill="#575757" HorizontalAlignment="Left" Height="51" Stroke="Black" VerticalAlignment="Top" Width="375" Margin="0,-2,0,0" Grid.ColumnSpan="2"/>
|
||||
<Label Content="Name" HorizontalAlignment="Left" Margin="10,6,0,0" VerticalAlignment="Top" Foreground="#FFFCFCFC" FontSize="22" Height="40" Width="125"/>
|
||||
<Label Content="Ortschaft" HorizontalAlignment="Left" Margin="10,51,0,0" VerticalAlignment="Top" Foreground="#FFFCFCFC" FontSize="22" Height="40"/>
|
||||
<Label Content="Personen Max." HorizontalAlignment="Left" Margin="10,102,0,0" VerticalAlignment="Top" Foreground="#FFFCFCFC" FontSize="22" Height="39"/>
|
||||
<Label Content="Zimmer" HorizontalAlignment="Left" Margin="10,152,0,0" VerticalAlignment="Top" Foreground="#FFFCFCFC" FontSize="22" Height="40"/>
|
||||
<Label Content="Preis" HorizontalAlignment="Left" Margin="10,201,0,0" VerticalAlignment="Top" Foreground="#FFFCFCFC" FontSize="22" Height="39"/>
|
||||
<Slider x:Name="personen_maximum" HorizontalAlignment="Left" Margin="175,114,0,0" VerticalAlignment="Top" Width="150" Height="18" Grid.ColumnSpan="2" IsSnapToTickEnabled="True" TickFrequency="1"/>
|
||||
<Label Content="{Binding ElementName=personen_maximum, Path=Value}" ContentStringFormat="{}{0:#}" HorizontalAlignment="Left" Margin="41,104,0,0" VerticalAlignment="Top" Foreground="White" FontSize="20" Height="39" Width="27" Grid.Column="1"/>
|
||||
<Slider x:Name="zimmer" HorizontalAlignment="Left" Margin="175,164,0,0" VerticalAlignment="Top" Width="150" Height="19" Grid.ColumnSpan="2" IsSnapToTickEnabled="True" TickFrequency="1"/>
|
||||
<Label Content="{Binding ElementName=zimmer, Path=Value}" HorizontalAlignment="Left" Margin="41,154,0,0" VerticalAlignment="Top" Foreground="White" FontSize="20" Height="40" Width="27" Grid.Column="1"/>
|
||||
<TextBox x:Name="preis_maximum" HorizontalAlignment="Left" Height="30" Margin="135,207,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="223" Grid.ColumnSpan="2"/>
|
||||
<Button x:Name="add" Content="ESTATE HINZUFÜGEN" HorizontalAlignment="Left" Margin="13,265,0,0" VerticalAlignment="Top" Width="348" Height="69" Background="#FF35B1AA" Foreground="White" FontSize="30" Click="addEstateButton" Grid.ColumnSpan="2"/>
|
||||
<TextBox x:Name="ortschaft" HorizontalAlignment="Left" Height="31" Margin="135,60,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="223" Grid.ColumnSpan="2"/>
|
||||
<TextBox x:Name="name" HorizontalAlignment="Left" Height="31" Margin="135,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="223" Grid.ColumnSpan="2"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using ferienhaus.Klassen;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -19,9 +21,58 @@ namespace ferienhaus
|
||||
/// </summary>
|
||||
public partial class AdminView : Window
|
||||
{
|
||||
public string ort { get; set; }
|
||||
public int personen { get; set; }
|
||||
public int zimmeranzahl { get; set; }
|
||||
public double preismax { get; set; }
|
||||
public DateTime ankunft { get; set; }
|
||||
public DateTime abfahrt { get; set; }
|
||||
|
||||
public AdminView()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Closing += new CancelEventHandler(MainWindow_Closing);
|
||||
}
|
||||
|
||||
void MainWindow_Closing(object sender, CancelEventArgs e)
|
||||
{
|
||||
MainWindow MW = new MainWindow();
|
||||
|
||||
MW.Show();
|
||||
}
|
||||
|
||||
public void getDataFromFields()
|
||||
{
|
||||
ort = this.ortschaft.Text;
|
||||
personen = Convert.ToInt32(this.personen_maximum.Value);
|
||||
zimmeranzahl = Convert.ToInt32(this.zimmer.Value);
|
||||
try
|
||||
{
|
||||
preismax = Convert.ToDouble(this.preis_maximum.Text);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("Preis ist ungültig!", "Fehler");
|
||||
}
|
||||
}
|
||||
|
||||
private void addEstateButton(object sender, RoutedEventArgs e)
|
||||
{
|
||||
getDataFromFields();
|
||||
|
||||
List<BookingTime> BTL = new List<BookingTime>();
|
||||
|
||||
Estate estate = new Estate()
|
||||
{
|
||||
EstateName = this.name.Text,
|
||||
Bedrooms = zimmeranzahl,
|
||||
Region = ort,
|
||||
Persons = personen,
|
||||
BookingTimes = BTL,
|
||||
Price = preismax
|
||||
};
|
||||
|
||||
EstateManager.getInstance().addEstate(estate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.ComponentModel;
|
||||
|
||||
using ferienhaus.Klassen;
|
||||
|
||||
@ -18,6 +19,17 @@ namespace ferienhaus
|
||||
|
||||
public static List<Estate> estates = new List<Estate>();
|
||||
|
||||
private void Window_Closing(object sender, CancelEventArgs e)
|
||||
{
|
||||
//foreach (var item in estates)
|
||||
//{
|
||||
// Data.Instance.write(item);
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
private void Window_Closed(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,6 +12,8 @@ namespace ferienhaus.Klassen
|
||||
{
|
||||
|
||||
private static Data instance = null;
|
||||
private static string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Ferienhaus";
|
||||
|
||||
|
||||
private Data()
|
||||
{
|
||||
@ -24,33 +26,42 @@ namespace ferienhaus.Klassen
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new Data();
|
||||
instance.init();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
public Estate read()
|
||||
public void init()
|
||||
{
|
||||
using (var reader = new StreamReader(File.OpenRead(@".\Data.json")))
|
||||
if (!Directory.Exists(appData))
|
||||
{
|
||||
return (Estate)JsonConvert.DeserializeObject(reader.ReadToEnd());
|
||||
Directory.CreateDirectory(appData);
|
||||
}
|
||||
if (!File.Exists(appData + "\\estate_data.json"))
|
||||
{
|
||||
File.Create(appData + "\\estate_data.json");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void write(Estate OBJ)
|
||||
public List<Estate> read()
|
||||
{
|
||||
using (StreamReader file = File.OpenText(appData + "\\estate_data.json"))
|
||||
{
|
||||
JsonSerializer serializer = new JsonSerializer();
|
||||
List<Estate> estates = (List<Estate>)serializer.Deserialize(file, typeof(List<Estate>));
|
||||
return estates;
|
||||
}
|
||||
}
|
||||
|
||||
public void write(List<Estate> OBJ)
|
||||
{
|
||||
|
||||
using (var write = new StreamWriter(File.OpenWrite(@".\Data.json")))
|
||||
using (StreamWriter file = File.CreateText(appData + "\\estate_data.json"))
|
||||
{
|
||||
string estateJson = JsonConvert.SerializeObject(OBJ);
|
||||
|
||||
write.Write(estateJson);
|
||||
JsonSerializer serializer = new JsonSerializer();
|
||||
serializer.Serialize(file, OBJ);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ferienhaus.Klassen
|
||||
{
|
||||
@ -15,14 +9,14 @@ namespace ferienhaus.Klassen
|
||||
public string Region { get; set; }
|
||||
public string CustomerID { get; set; }
|
||||
public List<BookingTime> BookingTimes { get; set; }
|
||||
|
||||
public string EstateName { get; set; }
|
||||
|
||||
|
||||
public Estate()
|
||||
{
|
||||
|
||||
}
|
||||
public Estate(int? bedrooms, int? persons, double? price, string region, string customerID, List<BookingTime> bookingTimes)
|
||||
public Estate(string estateName, int? bedrooms, int? persons, double? price, string region, string customerID, List<BookingTime> bookingTimes)
|
||||
{
|
||||
Bedrooms = bedrooms;
|
||||
Persons = persons;
|
||||
@ -30,6 +24,7 @@ namespace ferienhaus.Klassen
|
||||
Region = region;
|
||||
CustomerID = customerID;
|
||||
BookingTimes = bookingTimes;
|
||||
EstateName = estateName;
|
||||
}
|
||||
/*if((start < bisDat && start > vonDat) || (ende < bisDat && ende > vonDat) || (start < vonDat && ende > bisDat)) {
|
||||
frei = false;
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@ -14,11 +15,11 @@ namespace ferienhaus.Klassen
|
||||
public class EstateManager
|
||||
{
|
||||
private static EstateManager instance;
|
||||
private List<Estate> estates = new List<Estate>();
|
||||
public List<Estate> estates;
|
||||
|
||||
private EstateManager()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static EstateManager getInstance()
|
||||
@ -26,6 +27,7 @@ namespace ferienhaus.Klassen
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new EstateManager();
|
||||
instance.estates = new List<Estate>();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
@ -33,72 +35,57 @@ namespace ferienhaus.Klassen
|
||||
|
||||
public void addEstate(Estate estate)
|
||||
{
|
||||
this.estates.Add(estate);
|
||||
estates.Add(estate);
|
||||
Data.Instance.write(estates);
|
||||
MessageBox.Show("Added Esate " + estate.EstateName, "INFO");
|
||||
}
|
||||
|
||||
// mach mal lieber einen negativ-check in der schleife. Falls bedingung nicht erfüllt dann break;
|
||||
// ist sauberer als if in if in if ...
|
||||
|
||||
|
||||
|
||||
// ich würde das nach auschlussverfahren probieren. wenn ein attribut nicht übereinstimmtt dann mus der rest auch nicht abgechekct werden
|
||||
//achso verstehe
|
||||
|
||||
//ne ich glaube das geht nicht nach ausschlussverfahren
|
||||
//er muss ja durchiterieren durch sämtliche attribute.
|
||||
//es gibt für einen attribut keinen state der die abfrage beenden würde
|
||||
|
||||
// besser ?
|
||||
|
||||
//discord?
|
||||
|
||||
public void loadEstates()
|
||||
{
|
||||
List<Estate> estatesFromFile = Data.Instance.read();
|
||||
if (estatesFromFile != null)
|
||||
{
|
||||
this.estates = estatesFromFile;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Estate> checkAvailability(Estate reference)
|
||||
{
|
||||
loadEstates();
|
||||
|
||||
//https://docs.microsoft.com/de-de/dotnet/csharp/language-reference/operators/conditional-operator
|
||||
|
||||
List<Estate> List = new List<Estate>();
|
||||
List<Estate> foundEstates = new List<Estate>();
|
||||
|
||||
foreach (Estate estate in this.estates)
|
||||
{
|
||||
|
||||
if(estate.Bedrooms != reference.Bedrooms && reference.Bedrooms != null)
|
||||
if (estate.Bedrooms < reference.Bedrooms && reference.Bedrooms != null)
|
||||
{
|
||||
Debug.WriteLine("Search Estate Bedrooms: " + reference.Bedrooms + "| current estate in list: " + estate.Bedrooms);
|
||||
continue;
|
||||
if (estate.Persons != reference.Persons && reference.Persons != null)
|
||||
}
|
||||
if (estate.Persons < reference.Persons && reference.Persons != null)
|
||||
{
|
||||
Debug.WriteLine("Search Estate Persons: " + reference.Persons + "| current estate in list: " + estate.Persons);
|
||||
continue;
|
||||
if (estate.Price != reference.Price && reference.Price != null)
|
||||
}
|
||||
if (estate.Price - 1 >= reference.Price && reference.Price != null)
|
||||
{
|
||||
Debug.WriteLine("Search Estate Price: " + reference.Price + "| current estate in list: " + estate.Price);
|
||||
continue;
|
||||
}
|
||||
if (estate.Region != reference.Region && reference.Region != null)
|
||||
{
|
||||
Debug.WriteLine("Search Estate Region: " + reference.Region + "| current estate in list: " + estate.Region);
|
||||
continue;
|
||||
if (estate.CustomerID != reference.CustomerID && reference.CustomerID != null)
|
||||
continue;
|
||||
}
|
||||
if (estate.isBooked(reference.BookingTimes[0]) == true && reference.BookingTimes != null)
|
||||
continue;
|
||||
|
||||
|
||||
|
||||
if (estate.Bedrooms == reference.Bedrooms || estate.Bedrooms == null)
|
||||
{
|
||||
if (estate.Persons == reference.Persons || estate.Persons == null)
|
||||
{
|
||||
if (estate.Price == reference.Price || estate.Price == null)
|
||||
{
|
||||
if (estate.Region == reference.Region || estate.Region == "")
|
||||
{
|
||||
if (estate.CustomerID == reference.CustomerID || estate.CustomerID == "")
|
||||
{
|
||||
|
||||
List.Add(estate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foundEstates.Add(estate);
|
||||
|
||||
}
|
||||
|
||||
|
||||
return List;
|
||||
return foundEstates;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ferienhaus.Klassen
|
||||
{
|
||||
public class Landlord : User
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ferienhaus.Klassen
|
||||
{
|
||||
public class User
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -25,8 +25,8 @@ namespace ferienhaus
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// object mydata = Data.read();
|
||||
|
||||
// object mydata = Data.read();
|
||||
EstateManager.getInstance().loadEstates();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -5,13 +5,9 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:ferienhaus"
|
||||
mc:Ignorable="d"
|
||||
Title="Ferienhaus Suche" Height="421.6" Width="750">
|
||||
Title="Ferienhaus Suche" Height="421.6" Width="750"
|
||||
>
|
||||
<Grid HorizontalAlignment="Left" Height="453" Margin="0,0,0,0" VerticalAlignment="Top" Width="750">
|
||||
|
||||
|
||||
<!--Auf felder zugreifen (by x:name) :-->
|
||||
<!--TextBox ortschaft = (TextBox) this.FindName("ortschaft");-->
|
||||
|
||||
<Rectangle Fill="#575757" HorizontalAlignment="Left" Height="50" Stroke="Black" VerticalAlignment="Top" Width="375"/>
|
||||
<Rectangle Fill="#2e2e2e" HorizontalAlignment="Left" Height="50" Margin="0,50,0,0" Stroke="Black" VerticalAlignment="Top" Width="375"/>
|
||||
<Rectangle Fill="#575757" HorizontalAlignment="Left" Height="50" Margin="0,99,0,0" Stroke="Black" VerticalAlignment="Top" Width="375"/>
|
||||
@ -26,18 +22,29 @@
|
||||
<Label Content="Ankunft" HorizontalAlignment="Left" Margin="10,203,0,0" VerticalAlignment="Top" Foreground="#FFFCFCFC" FontSize="22"/>
|
||||
<Label Content="Abfahrt" HorizontalAlignment="Left" Margin="10,252,0,0" VerticalAlignment="Top" Foreground="#FFFCFCFC" FontSize="22"/>
|
||||
<TextBox x:Name="ortschaft" HorizontalAlignment="Left" Height="30" Margin="135,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="223"/>
|
||||
<Slider x:Name="personen_maximum" HorizontalAlignment="Left" Margin="175,67,0,0" VerticalAlignment="Top" Width="150"/>
|
||||
<Label Content="0" HorizontalAlignment="Left" Margin="338,57,0,0" VerticalAlignment="Top" Foreground="White" FontSize="20" Height="39" Width="27"/>
|
||||
<Slider x:Name="zimmer" HorizontalAlignment="Left" Margin="175,117,0,0" VerticalAlignment="Top" Width="150"/>
|
||||
<Label Content="0" HorizontalAlignment="Left" Margin="338,107,0,0" VerticalAlignment="Top" Foreground="White" FontSize="20" Height="39" Width="27"/>
|
||||
<Slider x:Name="personen_maximum" HorizontalAlignment="Left" Margin="175,67,0,0" VerticalAlignment="Top" Width="150" Minimum="0" Maximum="10" IsSnapToTickEnabled="True" TickFrequency="1"/>
|
||||
<Label Content="{Binding ElementName=personen_maximum, Path=Value}" HorizontalAlignment="Left" Margin="338,57,0,0" VerticalAlignment="Top" Foreground="White" FontSize="20" Height="39" Width="27"/>
|
||||
<Slider x:Name="zimmer" HorizontalAlignment="Left" Margin="175,117,0,0" VerticalAlignment="Top" Width="150" Minimum="0" Maximum="10" IsSnapToTickEnabled="True" TickFrequency="1"/>
|
||||
<Label Content="{Binding ElementName=zimmer, Path=Value}" HorizontalAlignment="Left" Margin="338,107,0,0" VerticalAlignment="Top" Foreground="White" FontSize="20" Height="39" Width="27"/>
|
||||
<TextBox x:Name="preis_maximum" HorizontalAlignment="Left" Height="30" Margin="135,159,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="223"/>
|
||||
<DatePicker x:Name="datum_ankunft" HorizontalAlignment="Left" Margin="135,211,0,0" VerticalAlignment="Top" Width="223" Height="22"/>
|
||||
<DatePicker x:Name="datum_abfahrt" HorizontalAlignment="Left" Margin="135,262,0,0" VerticalAlignment="Top" Width="223" Height="22"/>
|
||||
<Button x:Name="suche" Content="SUCHE" HorizontalAlignment="Left" Margin="13,312,0,0" VerticalAlignment="Top" Width="348" Height="68" Background="#FF35B1AA" Foreground="White" FontSize="30" Click="suche_Click"/>
|
||||
|
||||
<!--Hier estates in liste eintragen-->
|
||||
<ListBox x:Name="estate_liste" HorizontalAlignment="Left" Height="396" Margin="375,0,0,0" VerticalAlignment="Top" Width="375"/>
|
||||
|
||||
|
||||
<ListBox x:Name="estate_liste" HorizontalAlignment="Left" Height="396" Margin="375,0,0,0" VerticalAlignment="Top" Width="375">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Margin="0,3">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" VerticalAlignment="Center" Width="248" HorizontalAlignment="Center" Text="{Binding EstateName}" />
|
||||
<Button Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Right" Content="Jetzt Buchen" Width="100" Height="30" Background="#FF35B1AA" Foreground="White" FontSize="12" Click="bookEstate" Tag="{Binding EstateName}" ></Button>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</Grid>
|
||||
</Window>
|
||||
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -32,8 +33,19 @@ namespace ferienhaus
|
||||
public UserView()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Closing += new CancelEventHandler(MainWindow_Closing);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MainWindow_Closing(object sender, CancelEventArgs e)
|
||||
{
|
||||
MainWindow MW = new MainWindow();
|
||||
|
||||
MW.Show();
|
||||
}
|
||||
|
||||
|
||||
public void getDataFromFields()
|
||||
{
|
||||
ort = this.ortschaft.Text;
|
||||
@ -51,6 +63,7 @@ namespace ferienhaus
|
||||
abfahrt = this.datum_abfahrt.DisplayDate;
|
||||
}
|
||||
|
||||
|
||||
private void suche_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
getDataFromFields();
|
||||
@ -69,8 +82,45 @@ namespace ferienhaus
|
||||
|
||||
};
|
||||
|
||||
List<Estate> foundEstates = EstateManager.getInstance().checkAvailability(seachEstate);
|
||||
listFoundEstates(foundEstates);
|
||||
}
|
||||
|
||||
// EstateManager.getInstance().checkAvailability();
|
||||
public void listFoundEstates(List<Estate> estates)
|
||||
{
|
||||
List<EstateItem> estateListItem = new List<EstateItem>();
|
||||
foreach (Estate estate in estates)
|
||||
{
|
||||
estateListItem.Add(new EstateItem() { EstateName = estate.EstateName });
|
||||
}
|
||||
estate_liste.ItemsSource = estateListItem;
|
||||
}
|
||||
|
||||
private void bookEstate(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
((Button)sender).Content = "Gebucht!";
|
||||
string estateName = ((Button)sender).Tag.ToString();
|
||||
List<Estate> estates = EstateManager.getInstance().estates;
|
||||
|
||||
Estate bookEstate = null;
|
||||
// meins auch .-.
|
||||
foreach(Estate estate in estates)
|
||||
{
|
||||
if(estate.EstateName == estateName)
|
||||
{
|
||||
bookEstate = estate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
List<BookingTime> BTL = bookEstate.BookingTimes;
|
||||
BTL.Add(new BookingTime(ankunft, abfahrt));
|
||||
}
|
||||
}
|
||||
|
||||
class EstateItem
|
||||
{
|
||||
public string EstateName { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,9 +82,6 @@
|
||||
<Compile Include="Klassen\Estate.cs" />
|
||||
<Compile Include="Klassen\BookingTime.cs" />
|
||||
<Compile Include="Klassen\EstateManager.cs" />
|
||||
<Compile Include="Klassen\Landlord.cs" />
|
||||
<Compile Include="Klassen\Tenant.cs" />
|
||||
<Compile Include="Klassen\User.cs" />
|
||||
<Compile Include="UserView.xaml.cs">
|
||||
<DependentUpon>UserView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user