Skip to content

Commit

Permalink
find and prepare to correct picker selected item in edit pages
Browse files Browse the repository at this point in the history
  • Loading branch information
gwalus committed May 26, 2024
1 parent 64b412b commit c198243
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public async Task<IEnumerable<Expense>> GetAllAsync(DateOnly? from = null, DateO
{
var query = _dbContext.Expenses
.Include(x => x.Category)
.Include(x => x.Account)
.AsQueryable();

if (from.HasValue && to.HasValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,21 @@ public partial class EditExpensePageViewModel(IUnitOfWork unitOfWork) : Observab

private int id;

private decimal amount;
public decimal Amount
{
get => amount;
set => SetProperty(ref amount, value);
}
[ObservableProperty]
decimal _amount;

private Account selectedAccount;
public Account SelectedAccount
{
get => selectedAccount;
set => SetProperty(ref selectedAccount, value);
}
[ObservableProperty]
Account _selectedAccount;

private Category selectedCategory;
public Category SelectedCategory
{
get => selectedCategory;
set => SetProperty(ref selectedCategory, value);
}
[ObservableProperty]
Category _selectedCategory;

private DateTime date;
public DateTime Date
{
get => date;
set => SetProperty(ref date, value);
}
[ObservableProperty]
DateTime _date;

[ObservableProperty]
string _comment;

private string comment;
public string Comment
{
get => comment;
set => SetProperty(ref comment, value);
}
public DateTime MaximumDate { get; } = DateTime.Now;

public ObservableRangeCollection<Account> Accounts { get; } = [];
Expand All @@ -77,6 +58,7 @@ async Task Appearing()
Accounts.ReplaceRange(accounts);
Categories.ReplaceRange(categories);

// Doesn't work because we need to set the SelectedAccount property as Obserbable Property, in dto model
SelectedAccount = initialAccount;
}

Expand Down

0 comments on commit c198243

Please sign in to comment.