public async void AddTransaction() { try { if (_addTransaction.MoneyAmount == 0.0m)//|| _addTransaction.Category == null || _addTransaction.Currency == null) { // MessageBox.Show("Please, choose money amount,category and currency"); MessageBox.Show("Please, choose money amount"); return; } if (_addTransaction.Category == null) { MessageBox.Show("Please, choose category"); return; } if (_addTransaction.Currency == null) { MessageBox.Show("Please, choose currency"); return; } if (_addTransaction.Date == null) { MessageBox.Show("Please, choose date"); return; } if (DateTime.Compare(_addTransaction.Date.Value, DateTime.Today.AddDays(1)) > 0) { MessageBox.Show($" {_addTransaction.Date.Value} - Please, don`t look in the future..."); return; } IsEnabled = false; _addTransaction.Guid = Guid.NewGuid(); _wallet.AddTransaction(CurrentInformation.User, _addTransaction); //TODO: MAKE METHOD FOR UPDATE AFTER TRANSACTION await Task.Run(() => _walService.AddOrUpdateWalletAsync(_wallet)); await Task.Run(() => _tranService.AddOrUpdateTransactionAsync(_addTransaction)); MessageBox.Show("Adding wallet transaction completed!"); UpdateTransactionsCollection(); RaisePropertyChanged(nameof(DisplayName)); RaisePropertyChanged(nameof(Transactions)); RaisePropertyChanged(nameof(TenTransactions)); RaisePropertyChanged(nameof(LastMonthIncome)); RaisePropertyChanged(nameof(LastMonthExpense)); } catch (Exception ex) { MessageBox.Show($"Adding wallet transaction failed {ex.Message}"); } finally // is done independently from exception { IsEnabled = true; } }