public void GenerateReadings() { if (Repeat && Cycle == 1) { foreach (var swvm in WeekDayList.Where(wd => wd.IsSelected)) { var dayOfWeek = new DomainModelService.DayOfWeek(); dayOfWeek.WeekDay = (int)swvm.DayOfWeek; Model.WeekDays.Add(dayOfWeek); } } foreach (var scvm in m_Container.Where(scvm => scvm.IsSelected)) { var result = m_TaskGenerator.GenerateMeterReadings(scvm.MeterViewModel.Model, SelectedResponsibleSubject.Model, Model, WeekDayList.Where(wd => wd.IsSelected) .Select(wd => wd.DayOfWeek) .ToArray()); foreach (var reading in result) { m_Repository.MeterReadings.Add(reading); } } m_Repository.Save(); TryClose(); }
public SettingsPage(FormWindowState previousWinstate) { InitializeComponent(); LoadAlternativeDays(); // checks if a week has 7 days if (WeekDayList.Count != 7) { MessageBox.Show("Er is iets fout gegaan tijdens het ophalen van de dagen."); WeekDayList.Clear(); for (int i = 0; i < 7; i++) { WeekDayList.Add(new DePandaClassLib.Entities.WeekDay(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 9, 0, 0), new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 19, 0, 0))); } } // checkt in welke modus het scherm is if (previousWinstate == FormWindowState.Maximized) { PanelAlternativeDay.Location = new Point(525, 82); } else { PanelAlternativeDay.Location = new Point(12, 466); } LoadWeekDays(); }
public void GenerateReadings() { if (Repeat && Cycle == 1) { foreach (var swvm in WeekDayList.Where(wd => wd.IsSelected)) { var dayOfWeek = new DomainModelService.DayOfWeek(); dayOfWeek.WeekDay = (int)swvm.DayOfWeek; m_Model.WeekDays.Add(dayOfWeek); } } var selectedConditionInspections = new ObservableCollection <ConditionInspection>(); foreach (var scvm in m_SelectableAuxillaryConditionViewModels.Where(scvm => scvm.IsSelected)) { var ciModel = new ConditionInspection(); ciModel.AuxillaryConditionId = scvm.Model.Id; selectedConditionInspections.Add(ciModel); //SaveInAuxillaryCondition(ciModel, scvm.Model); } var result = m_TaskGenerator.GenerateInspections(selectedConditionInspections, SelectedResponsibleSubject.Model, m_Model, WeekDayList.Where(wd => wd.IsSelected) .Select(wd => wd.DayOfWeek) .ToArray()); foreach (var reading in result) { foreach (var conditionInspection in reading.ConditionInspections) { m_Repository.ConditionInspections.Add(conditionInspection); } m_Repository.Inspections.Add(reading); } m_Repository.Save(); TryClose(); }
private void SelectWeekDays() { if (!Repeat || Cycle != 1) { return; } foreach (var selectableWeekdayViewModel in Model.WeekDays.SelectMany(weekDay => WeekDayList.Where(selectableWeekdayViewModel => selectableWeekdayViewModel.DayOfWeek == weekDay.GetAsDayOfWeek())) ) { selectableWeekdayViewModel.IsSelected = true; } }