Skip to content

Commit

Permalink
Merge pull request #50 from YBTopaz8/45-edits-not-reflected-on-popup-…
Browse files Browse the repository at this point in the history
…close

- Edited logic for adding/editing Flow Outs so that the collectionvie…
  • Loading branch information
YBTopaz8 authored Jun 21, 2023
2 parents 7359348 + 5c836d8 commit 6546de7
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions FlowHub.Main/ViewModels/Expenditures/ManageExpendituresVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public async void FilterGetAllExp()
filterOption = "Filter_All";
List<ExpendituresModel> expList = new ();

expList = expendituresService.OfflineExpendituresList.OrderByDescending(x => x.DateSpent).ToList();
expList = ExpendituresList is not null ? ExpendituresList.OrderByDescending(x => x.DateSpent).ToList() : expendituresService.OfflineExpendituresList.OrderByDescending(x => x.DateSpent).ToList();
FilterTitle = "Date Spent Descending";

var tempList = await Task.Run(() => new ObservableCollection<ExpendituresModel>(expList));
Expand Down Expand Up @@ -393,10 +393,22 @@ private async Task AddEditExpediture(ExpendituresModel newExpenditure, string pa
if (UpSertResult.Result == PopupResult.OK)
{
ExpendituresModel exp = (ExpendituresModel)UpSertResult.Data;
ExpendituresList.Add(exp);
expendituresService.OfflineExpendituresList.Add(exp);
TotalAmount += exp.AmountSpent;
TotalExpenditures++;
if (isAdd)
{
ExpendituresList.Add(exp);
TotalAmount += exp.AmountSpent;
TotalExpenditures++;
FilterGetAllExp();
}
else
{
// Get the old expenditure before replacing it
var oldExp = ExpendituresList[ExpendituresList.IndexOf(nExp)];
ExpendituresList[ExpendituresList.IndexOf(nExp)] = exp;

// Adjust total amount and total expenditures
TotalAmount = TotalAmount - oldExp.AmountSpent + exp.AmountSpent;
}
}
}

Expand Down Expand Up @@ -444,7 +456,7 @@ public async void DeleteExpenditureBtn(ExpendituresModel expenditure)
const ToastDuration duration = ToastDuration.Short;
const double fontSize = 14;
string text;
bool response = (bool)(await Shell.Current.ShowPopupAsync(new AcceptCancelPopUpAlert("Do You want to DELETE?")))!;
bool response = (bool)(await Shell.Current.ShowPopupAsync(new AcceptCancelPopUpAlert("Do You want to Delete?")))!;
if (response)
{
IsBusy = true;
Expand All @@ -469,6 +481,7 @@ public async void DeleteExpenditureBtn(ExpendituresModel expenditure)
await toast.Show(cancellationTokenSource.Token); //toast a notification about exp deletion
Sorting(GlobalSortNamePosition);
IsBusy = false;

}
}

Expand Down

0 comments on commit 6546de7

Please sign in to comment.