public async void LoadWorktimes() { await proxy.Reload(); List <Worktimes> worktimes = await proxy.GetAllWorktimesOfDay(_viewmodel.Date); if (worktimes.Count == 0) { worktimes = await proxy.GetAllWorktimesOfDay(_viewmodel.Date); } _viewmodel.Worktimes.Clear(); foreach (var worktime in worktimes) { try { Employees emp = await EmployeeCatalog.GetSingleAsync(worktime.EmployeeID.ToString()); WorktimeEventDetails WTevent = new WorktimeEventDetails(emp, worktime); WTevent.AttachSubscriber(_viewmodel); _viewmodel.Worktimes.Add(new WorktimeEventDetails(emp, worktime)); } catch (Exception e) { _viewModelBase.ErrorList.Add(e.Message); } } }
/// <summary> /// Finder worktimes i Databasen og sætter dem ind i TimeplanColletions. /// </summary> /// <returns></returns> protected virtual async Task PopulateTimePlanCollectionsAsync() { int headerindex = 1; foreach (var header in _viewmodel.Headers) { //Her finder vi alle worktimes som er på en given dag. List <Worktimes> WorktimesThisDay = await _catalogInterface.GetAllWorktimesOfDay(header.Date, header.Year); foreach (Worktimes worktime in WorktimesThisDay) { // Her tilføjer vi de worktimes til timePlanCollections. dato og cællerne følger hindanden ved hjælp af headerindex switch (headerindex) { case 1: { await FindAndAddEmployeesToTimePlanAsync(_timePlanCollection1, worktime); break; } case 2: { await FindAndAddEmployeesToTimePlanAsync(_timePlanCollection2, worktime); break; } case 3: { await FindAndAddEmployeesToTimePlanAsync(_timePlanCollection3, worktime); break; } case 4: { await FindAndAddEmployeesToTimePlanAsync(_timePlanCollection4, worktime); break; } case 5: { await FindAndAddEmployeesToTimePlanAsync(_timePlanCollection5, worktime); break; } case 6: { await FindAndAddEmployeesToTimePlanAsync(_timePlanCollection6, worktime); break; } case 7: { await FindAndAddEmployeesToTimePlanAsync(_timePlanCollection7, worktime); break; } } } headerindex++; } // Her opdatere vi vievet. UpdateTimePlan(); }