private void collectData() { var customers = service.GetAllCustomers(); var reservations = service.GetAllReservations(); var loans = service.GetAllLoans(); AllCustomer.Clear(); foreach (Customer c in customers) { List <Loan> cLoans = getLoans(c, loans); AllCustomer.Add(new AllOfCustomer(c.Studentnumber, c.Name, getReservations(c, reservations), cLoans, getToBackInformations(cLoans))); } foreach (Reservation r in reservations) { AllReservations.Add(new ReserveByUser(r.Customer.Name, r.Gadget.Name, r.WaitingPosition, r.IsReady)); } foreach (Loan l in loans) { DateTime?date = l.ReturnDate; if (l.ReturnDate == null) { date = l.OverDueDate; } AllLoans.Add(new LoansByUser(l.Gadget.Name, l.Customer.Name, date, l.IsOverdue, getResByGadget(l, reservations))); } }
public MainWindowViewModel() { dataService = new LibraryAdminService(ConfigurationManager.AppSettings.Get("server")?.ToString()); try { Gadgets = new ObservableCollection <GadgetViewModel>(dataService.GetAllGadgets() .Select(g => new GadgetViewModel(g))); SelectedGadget = Gadgets.FirstOrDefault(); Customers = new ObservableCollection <CustomerViewModel>(dataService.GetAllCustomers() .Select(c => { var customerViewModel = new CustomerViewModel(c); customerViewModel.DataChanged += OnCustomerDataChanged; return(customerViewModel); })); SelectedCustomer = Customers.FirstOrDefault(); //dataService.DeleteLoan(dataService.GetLoan("d4b05cc5-5948-472a-bbfd-600b4d7578fa")); Loans = new ObservableCollection <LoanViewModel>(dataService.GetAllLoans() .Select(l => new LoanViewModel(l))); SelectedLoan = Loans.FirstOrDefault(); } catch (Exception ex) { MessageBox.Show("Beim Laden ist ein Problem aufgetreten.", ex.Message, MessageBoxButton.OK); return; } }
public Ausleihe() { InitializeComponent(); var service = new LibraryAdminService("http://mge5.dev.ifs.hsr.ch/"); var gadgets = service.GetAllGadgets(); var customers = service.GetAllCustomers(); var reservations = service.GetAllReservations(); var loans = service.GetAllLoans(); List <AllOfCustomer> allCustomer = new List <AllOfCustomer>(); foreach (Customer c in customers) { List <Loan> cLoans = getLoans(c, loans); allCustomer.Add(new AllOfCustomer(c.Studentnumber, c.Name, getReservations(c, reservations), cLoans, getToBackInformations(cLoans))); } GadgetsByUser.ItemsSource = allCustomer; CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(GadgetsByUser.ItemsSource); view.Filter = UserFilter1; List <ReserveByUser> allReservations = new List <ReserveByUser>(); foreach (Reservation r in reservations) { allReservations.Add(new ReserveByUser(r.Customer.Name, r.Gadget.Name, r.WaitingPosition, r.IsReady)); } ReservationsByUsers.ItemsSource = allReservations; CollectionView view2 = (CollectionView)CollectionViewSource.GetDefaultView(ReservationsByUsers.ItemsSource); view2.Filter = UserFilter2; List <LoansByUser> allLoans = new List <LoansByUser>(); foreach (Loan l in loans) { if (l.Gadget != null) { allLoans.Add(new LoansByUser(l.Gadget.Name, l.Customer.Name, l.ReturnDate, l.IsOverdue, getResByGadget(l, reservations))); } } LeansByGadget.ItemsSource = allLoans; CollectionView view3 = (CollectionView)CollectionViewSource.GetDefaultView(LeansByGadget.ItemsSource); view3.Filter = UserFilter3; }
/// <summary> /// demonstrates how to get the full inventory from the gadgeothek /// </summary> public void ShowInventory() { var service = new LibraryAdminService(ServerUrl); // no need to login as admin, woohoo :-) var gadgets = service.GetAllGadgets(); PrintAll(gadgets); var customers = service.GetAllCustomers(); PrintAll(customers); var reservations = service.GetAllReservations(); PrintAll(reservations); var loans = service.GetAllLoans(); PrintAll(loans); }
public MainWindow() { InitializeComponent(); service = new LibraryAdminService(ConfigurationSettings.AppSettings.Get("server")); var client = new websocket.WebSocketClient(ConfigurationSettings.AppSettings.Get("server")); this.DataContext = this; Gadgets = new ObservableCollection <Gadget>(service.GetAllGadgets()); Loans = new ObservableCollection <Loan>(service.GetAllLoans()); List <domain.Customer> customers = service.GetAllCustomers(); List <domain.Reservation> reservations = service.GetAllReservations(); //gadgetGrid.ItemsSource = gadgets; //loanGrid.ItemsSource = loans; reservationGrid.ItemsSource = reservations; customerGrid.ItemsSource = customers; client.NotificationReceived += (o, e) => { Console.WriteLine("WebSocket::Notification: " + e.Notification.Target + " > " + e.Notification.Type); // demonstrate how these updates could be further used if (e.Notification.Target == typeof(Loan).Name.ToLower()) { // deserialize the json representation of the data object to an object of type Gadget var loan = e.Notification.DataAs <Loan>(); // now you can use it as usual... //Console.WriteLine("Details: " + gadget); Loans.Add(loan); } }; // spawn a new background thread in which the websocket client listens to notifications from the server var bgTask = client.ListenAsync(); }
public List <Customer> GetAllClients() => Service.GetAllCustomers();
public void LoadCustomers() { AllCustomers = Service.GetAllCustomers(); NewCustomer(); }