public void SaveWindow() { if (AddAccount) { MainVM.Balances.Add(new Models.Balance { Name = EditAccount }); MainVM.ToSaveBalances = true; SelectedBalance = MainVM.Balances.Count - 1; SelectBalance(SelectedBalance); } if (MainVM.Balances[SelectedBalance].Name != EditAccount) { MainVM.Balances[SelectedBalance].Name = EditAccount; MainVM.ToSaveBalances = true; } if (!string.IsNullOrEmpty(EditAmount.ToString())) { if (AddBalance) { MainVM.Balances[SelectedBalance].Amounts.Add(new Models.BalanceAmount { Date = EditDate.Date, Amount = EditAmount.Value }); } else { CurrentAmount.Date = EditDate.Date; CurrentAmount.Amount = EditAmount.Value; } MainVM.ToSaveBalances = true; } if (MainVM.ToSaveBalances) { MainVM.GetCurrentBalances(); } EditBalanceView.Close(); }