private void Periods_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { Periods.Clear(); foreach (PeriodViewModel period in MainViewModel.Instance.Parameters.Periods) { Periods.Add(period); } SelectedPeriod = Periods.FirstOrDefault(); }
public void SetManualDate(DateTime date) { isPeriodChangedSuppressed = true; StartDate = date; EndDate = date.AddDays(1).AddSeconds(-1); SelectedPeriod = Periods.FirstOrDefault(p => p.IsManual); if (SelectedPeriod != null) { PeriodChanged.OnNext(Unit.Default); } isPeriodChangedSuppressed = false; }
public ValidityPeriod GetOrAddPeriod(int sequence) { var period = Periods.FirstOrDefault(p => p.Sequence == sequence); if (period == null) { period = new ValidityPeriod { Sequence = sequence }; Periods.Add(period); } return(period); }
public Period PostPeriod(Period period) { period.AccountId = Session.DefaultAccount.AccountId; var item = Periods.FirstOrDefault(c => c.PeriodId == period.PeriodId); if (item != null) { item = period; return(item); } else { period.PeriodId = GeneratePeriodId(); Periods.Add(period); return(period); } }
private void CmdAddPeriod() { var date = NewPeriodTill.Date; if (Periods.FirstOrDefault(p => p.Till == date) != null) { _editor.SetSaveError(LocalizedStrings.Str1427, true); return; } var index = _periods.IndexOf(p => p.Till > date); if (index < 0) { _periods.Add(new WorkingTimePeriodViewModel(date)); } else { _periods.Insert(index, new WorkingTimePeriodViewModel(date)); } OnDataChanged(); }