private async Task UpdateBanenInfoAsync() { try { if (_vereniging == null) { _vereniging = await _verenigingRepository.GetVerenigingAsync(); } if (_afhang == null) { _afhang = await _verenigingRepository.GetVerenigingSettingsAsync(); } List <Baan> banen = await _baanRepository.GetBanenByDateAsync(_vereniging.Id, _vereniging.AccommodatieId, DateTime.Now); ResourceType banenResource = new ResourceType { TypeName = "Banen" }; foreach (Baan baan in banen) { banenResource.ResourceCollection.Add(new Resource { DisplayName = baan.Naam, ResourceName = baan.Naam, TypeName = "Banen" }); } Banen.Add(banenResource); } catch (Exception ex) { string message = ex.Message; throw; } }
private async void BanenSchema_VisibleDatesChanging(VisibleDatesChangingEventArgs e) { try { ObservableCollection <DateTime> dates = e.NewValue as ObservableCollection <DateTime>; DateTime _date = DateTime.Now; if (dates.Count > 0) { _date = dates[0]; } if (_vereniging == null) { _vereniging = await _verenigingRepository.GetVerenigingAsync(); } if (_afhang == null) { _afhang = await _verenigingRepository.GetVerenigingSettingsAsync(); } List <Baan> banen = await _baanRepository.GetBanenByDateAsync(_vereniging.Id, _vereniging.AccommodatieId, _date); ResourceType banenResource = new ResourceType { TypeName = "Banen" }; Reserveringen = new ObservableCollection <ScheduleAppointment>(); foreach (Baan baan in banen) { banenResource.ResourceCollection.Add(new Resource { DisplayName = baan.Naam, ResourceName = baan.Naam, TypeName = "Banen" }); /* * int hours = new Random().Next(Afhang.BaanBegin.Hours, Afhang.BaanEinde.Hours); * int mins = new Random().Next(Afhang.Duur_Een, Afhang.Duur_Vier); * Reserveringen.Add(new ScheduleAppointment { StartTime = _date.AddHours(hours).AddMinutes(mins * -1), EndTime = _date.AddHours(hours).AddMinutes(mins), Location = "Baan 1", Status = new ScheduleAppointmentStatus { Status = ReserveringSoort.Les.ToString() }, ResourceCollection = new ObservableCollection<Resource> { new Resource() { ResourceName = baan.Naam, TypeName = "Banen" } }, Subject = "Afhangen", ReadOnly = true }); * * hours = new Random().Next(Afhang.BaanBegin.Hours, Afhang.BaanEinde.Hours); * mins = new Random().Next(Afhang.Duur_Een, Afhang.Duur_Vier); * Reserveringen.Add(new ScheduleAppointment { StartTime = _date.AddHours(hours).AddMinutes(mins * -1), EndTime = _date.AddHours(hours).AddMinutes(mins), Location = "Baan 1", Status = new ScheduleAppointmentStatus { Status = ReserveringSoort.Afhangen.ToString() }, ResourceCollection = new ObservableCollection<Resource> { new Resource() { ResourceName = baan.Naam, TypeName = "Banen" } }, Subject = "Afhangen", ReadOnly = true }); * * hours = new Random().Next(Afhang.BaanBegin.Hours, Afhang.BaanEinde.Hours); * mins = new Random().Next(Afhang.Duur_Een, Afhang.Duur_Vier); * Reserveringen.Add(new ScheduleAppointment { StartTime = _date.AddHours(hours).AddMinutes(mins * -1), EndTime = _date.AddHours(hours).AddMinutes(mins), Location = "Baan 1", Status = new ScheduleAppointmentStatus { Status = ReserveringSoort.Competitie.ToString() }, ResourceCollection = new ObservableCollection<Resource> { new Resource() { ResourceName = baan.Naam, TypeName = "Banen" } }, Subject = "Afhangen", ReadOnly = true }); */ } Banen.Add(banenResource); ObservableCollection <Reservering> reserveringen = await _reserveringRepository.GetReserveringenByDateAsync(_date); foreach (Reservering reservering in reserveringen) { reservering.Baan = banen.SingleOrDefault <Baan>(b => b.Id == reservering.BaanId); if (reservering.Baan != null) { //reservering.BaanId Reserveringen.Add( new ScheduleAppointment { StartTime = reservering.Datum.Add(reservering.BeginTijd), EndTime = reservering.Datum.Add(reservering.EindTijd), Location = reservering.Baan.Naam, Status = new ScheduleAppointmentStatus { Status = reservering.Soort.ToString() }, ResourceCollection = new ObservableCollection <Resource> { new Resource() { ResourceName = reservering.Baan.Naam, TypeName = "Banen" } }, Subject = String.IsNullOrWhiteSpace(reservering.Beschrijving) ? reservering.Soort.ToString() : reservering.Beschrijving, ReadOnly = true }); } } } catch (Exception ex) { string message = ex.Message; //throw; } }