CineBook Projekt hinzugefügt
This commit is contained in:
36
Views/MyBookingsView.xaml.cs
Normal file
36
Views/MyBookingsView.xaml.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using CineBook.Data;
|
||||
using CineBook.Models;
|
||||
using System.Linq;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace CineBook.Views;
|
||||
|
||||
public partial class MyBookingsView : UserControl
|
||||
{
|
||||
private readonly Repository _repo;
|
||||
private readonly User _user;
|
||||
|
||||
public MyBookingsView(Repository repo, User user)
|
||||
{
|
||||
InitializeComponent();
|
||||
_repo = repo;
|
||||
_user = user;
|
||||
UserNameText.Text = $"Angemeldet als: {user.Username} ({user.Role}) | {user.Email}";
|
||||
Load();
|
||||
}
|
||||
|
||||
private void Load()
|
||||
{
|
||||
try
|
||||
{
|
||||
var bookings = _repo.GetBookingsByUser(_user.UserID);
|
||||
MyGrid.ItemsSource = bookings;
|
||||
|
||||
TotalBookingsText.Text = bookings.Count.ToString();
|
||||
TotalSpentText.Text = bookings.Where(b => b.Status == "Confirmed").Sum(b => b.TotalPrice).ToString("F2") + " €";
|
||||
ActiveBookingsText.Text = bookings.Count(b => b.Status == "Confirmed").ToString();
|
||||
StatusText.Text = $"● {bookings.Count} Buchungen gefunden.";
|
||||
}
|
||||
catch (System.Exception ex) { StatusText.Text = "⚠ Fehler: " + ex.Message; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user