private async void DeleteTransaction(object parameter) { var transaction = (ITransaction)parameter; try { var user = JsonConvert.DeserializeObject <User>(await HttpRequestHelper.GetUserByEmailRemote(ViewBag.Email)); if (user != null) { if (transaction.IsExpense) { var expense = JsonConvert.DeserializeObject <Lipwig.Models.Expense>(await HttpRequestHelper.GetExpenseRemote(transaction.Id)); user.Expenses.Remove(expense); user.Balance += expense.Amount; ViewBag.Balance = user.LocalizedBalance; var responseUser = JsonConvert.DeserializeObject <GeneralResponse>(await HttpRequestHelper.UpdateUserRemote(user)); if (responseUser.Status == "0") { throw new Exception(); } var responseExpense = JsonConvert.DeserializeObject <GeneralResponse>(await HttpRequestHelper.DeleteExpenseRemote(expense)); if (responseExpense.Status == "0") { throw new Exception(); } } else { var income = JsonConvert.DeserializeObject <Lipwig.Models.Income>(await HttpRequestHelper.GetIncomeRemote(transaction.Id)); user.Incomes.Remove(income); user.Balance -= income.Amount; ViewBag.Balance = user.LocalizedBalance; var responseUser = JsonConvert.DeserializeObject <GeneralResponse>(await HttpRequestHelper.UpdateUserRemote(user)); if (responseUser.Status == "0") { throw new Exception(); } var responseIncome = JsonConvert.DeserializeObject <GeneralResponse>(await HttpRequestHelper.DeleteIncomeRemote(income)); if (responseIncome.Status == "0") { throw new Exception(); } } this.SuccessfulDeleteRequested(); this.Transactions.Remove(transaction); } } catch { } }