Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- Edited logic for adding/editing Flow Outs so that the collectionvie… #50

Merged
merged 1 commit into from
Jun 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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