Task IEventHandler <OutcomeWhenChanged> .HandleAsync(OutcomeWhenChanged payload) { OutcomeOverviewViewModel viewModel = Items.FirstOrDefault(vm => payload.AggregateKey.Equals(vm.Key)); if (viewModel != null) { viewModel.When = payload.When; if (Period is MonthModel month) { MonthModel newValue = payload.When; if (month != newValue) { Items.Remove(viewModel); } } else if (Period is YearModel year) { YearModel newValue = new YearModel(payload.When.Year); if (year != newValue) { Items.Remove(viewModel); } } } return(Task.CompletedTask); }
Task IEventHandler <OutcomeDescriptionChanged> .HandleAsync(OutcomeDescriptionChanged payload) { OutcomeOverviewViewModel viewModel = Items.FirstOrDefault(vm => payload.AggregateKey.Equals(vm.Key)); if (viewModel != null) { viewModel.Description = payload.Description; } return(Task.CompletedTask); }
Task IEventHandler <OutcomeAmountChanged> .HandleAsync(OutcomeAmountChanged payload) { OutcomeOverviewViewModel viewModel = Items.FirstOrDefault(vm => payload.AggregateKey.Equals(vm.Key)); if (viewModel != null) { viewModel.Amount = payload.NewValue; Sort(lastSortDescriptor); } return(Task.CompletedTask); }