private void UpdateSoba() { SelektovanaSoba.Sifra = Convert.ToInt32(SifraTb.Text); SelektovanaSoba.Kapacitet = Convert.ToInt32(KapacitetTb.Text); SelektovanaSoba.Zauzetost = Convert.ToInt32(ZauzetostTb.Text); SelektovanaSoba.Pocetak = (DateTime)PocetakTb.SelectedDate; SelektovanaSoba.Tip = (TypeOfUsage)TipCb.SelectedItem; SelektovanaSoba.Kraj = (DateTime)KrajTb.SelectedDate; RoomController roomController = new RoomController(); RenovationPeriodController renovationPeriodController = new RenovationPeriodController(); RenovationPeriod p = new RenovationPeriod(); Room room = new Room(); room.Capacity = SelektovanaSoba.Kapacitet; room.Number = SelektovanaSoba.Sifra; room.Occupation = SelektovanaSoba.Zauzetost; if (SelektovanaSoba.Pocetak == DateTime.Today && SelektovanaSoba.Kraj == DateTime.Today) { room.Renovation = false; renovationPeriodController.CancelRenovation(room.Number); } else if (SelektovanaSoba.Pocetak == DateTime.MinValue && SelektovanaSoba.Kraj == DateTime.MinValue) { room.Renovation = false; renovationPeriodController.CancelRenovation(room.Number); } else { if (renovationPeriodController.ViewRenovationByRoomNumber(room.Number) != null) { room.Renovation = true; p.room = room; p.BeginDate = SelektovanaSoba.Pocetak; p.EndDate = SelektovanaSoba.Kraj; renovationPeriodController.EditRenovation(p); } else { room.Renovation = true; p.room = room; p.BeginDate = SelektovanaSoba.Pocetak; p.EndDate = SelektovanaSoba.Kraj; renovationPeriodController.ScheduleRenovation(p); } } roomController.EditRoom(room); }
private void buttonObrisiSalu_Click(object sender, RoutedEventArgs e) { if (SelektovanaSoba == null || string.IsNullOrWhiteSpace(SelektovanaSoba.Sifra.ToString())) { return; } foreach (Soba soba in TempSobe) { if (soba.Sifra == SelektovanaSoba.Sifra) { RoomController roomController = new RoomController(); RenovationPeriodController renovationPeriodController = new RenovationPeriodController(); renovationPeriodController.CancelRenovation(soba.Sifra); roomController.DeleteRoom(soba.Sifra); //EquipmentInRoomsController ec = new EquipmentInRoomsController(); //ec.deleteLeftEquipmentInRooms(soba.Sifra); ExaminationController exc = new ExaminationController(); exc.DeleteRoomExaminations(soba.Sifra); PlacementInSickRoomController pc = new PlacementInSickRoomController(); pc.DeleteRoomPlacements(soba.Sifra); DoctorController dc = new DoctorController(); UserController uc = new UserController(dc); List <User> lista = uc.ViewAllUsers(); foreach (Doctor d in lista) { Doctor n = (Doctor)d; n.DoctorsOffice = new Room(); List <Room> rooms = roomController.ViewRooms(); n.DoctorsOffice = rooms.First(); } SelektovanaSoba = null; ClearFields(); UpdateTempSoba(); break; } } }