private void UpdateTempSoba() { Sobe.Clear(); TempSobe.Clear(); RoomController roomController = new RoomController(); RenovationPeriodController renovationPeriodController = new RenovationPeriodController(); List <Room> rooms = roomController.ViewRooms(); List <RenovationPeriod> periods = renovationPeriodController.ViewRenovations(); if (rooms != null) { foreach (Room r in rooms) { if (periods != null) { foreach (RenovationPeriod p in periods) { if (r.Number == p.room.Number) { Sobe.Add(new Soba() { Sifra = r.Number, Kapacitet = r.Capacity, Zauzetost = r.Occupation, Tip = r.Usage, Pocetak = p.BeginDate, Kraj = p.EndDate }); r.Renovation = true; } } } if (r.Renovation == false) { Sobe.Add(new Soba() { Sifra = r.Number, Kapacitet = r.Capacity, Zauzetost = r.Occupation, Tip = r.Usage }); } } } foreach (var soba in Sobe) { TempSobe.Add(soba); } }
public RoomsView() { InitializeComponent(); this.DataContext = this; this.izaberiTip(); Sobe = new ObservableCollection <Soba>(); TempSobe = new ObservableCollection <Soba>(); Kriterijumi = new ObservableCollection <string>(); Kriterijumi.Add("Sifra"); SifraTb.IsEnabled = true; RoomController roomController = new RoomController(); List <Room> rooms = roomController.ViewRooms(); RenovationPeriodController renovationPeriodController = new RenovationPeriodController(); List <RenovationPeriod> periods = renovationPeriodController.ViewRenovations(); if (rooms != null) { foreach (Room r in rooms) { if (periods != null) { foreach (RenovationPeriod p in periods) { if (r.Number == p.room.Number) { Sobe.Add(new Soba() { Sifra = r.Number, Kapacitet = r.Capacity, Zauzetost = r.Occupation, Tip = r.Usage, Pocetak = p.BeginDate, Kraj = p.EndDate }); r.Renovation = true; } } } if (r.Renovation == false) { Sobe.Add(new Soba() { Sifra = r.Number, Kapacitet = r.Capacity, Zauzetost = r.Occupation, Tip = r.Usage }); } } } //Sobe.Add(new Soba() { Kapacitet = "3", Sifra = "djna" , Tip="Operaciona sala",Zauzetost="0", Pocetak = Convert.ToDateTime("1/12/2020"), Kraj = Convert.ToDateTime("1/12/2020") }); //Sobe.Add(new Soba() { Kapacitet = "30", Sifra = "aadjna",Pocetak=Convert.ToDateTime("1/12/2020"),Kraj= Convert.ToDateTime("1/12/2020") }); //Sobe.Add(new Soba() { Kapacitet = "40", Sifra = "jdjna", Pocetak = Convert.ToDateTime("1/12/2020"), Kraj = Convert.ToDateTime("1/12/2020") }); //Sobe.Add(new Soba() { Kapacitet = "4000", Sifra = "ccdjna", Pocetak = Convert.ToDateTime(null), Kraj = Convert.ToDateTime(null) }); //Sobe.Add(new Soba() { Kapacitet = "50", Sifra = "aadjna", Pocetak = Convert.ToDateTime(null), Kraj = Convert.ToDateTime(null) }); //Sobe.Add(new Soba() { Kapacitet = "3", Sifra = "djakda", Tip = "Operaciona sala", Zauzetost = "0", Pocetak = Convert.ToDateTime("1/12/2020"), Kraj = Convert.ToDateTime("1/12/2020") }); //Sobe.Add(new Soba() { Kapacitet = "3", Sifra = "123", Tip = "Operaciona sala", Zauzetost = "0", Pocetak = Convert.ToDateTime("1/12/2020"), Kraj = Convert.ToDateTime("1/12/2020") }); //Sobe.Add(new Soba() { Kapacitet = "3", Sifra = "987", Tip = "Operaciona sala", Zauzetost = "0", Pocetak = Convert.ToDateTime("1/12/2020"), Kraj = Convert.ToDateTime("1/12/2020") }); //Sobe.Add(new Soba() { Kapacitet = "3", Sifra = "23456789", Tip = "Operaciona sala", Zauzetost = "0", Pocetak = Convert.ToDateTime("1/12/2020"), Kraj = Convert.ToDateTime("1/12/2020") }); foreach (var soba in Sobe) { TempSobe.Add(soba); } SelectedKriterijum = Kriterijumi[0]; SifraHint = "Unesi broj"; PocetakHint = "Izaberi datum"; KrajHint = "Izaberi datum"; TipHint = "Unesi tekst"; KapacitetHint = "Unesi broj"; ZauzetostHint = "Unesi broj"; PretragaHint = "Unesi tekst za pretragu"; SelektovanaSoba = null; }