diff --git a/Billing.Shared/Models/Category.cs b/Billing.Shared/Models/Category.cs index 9726509..03b9cb4 100644 --- a/Billing.Shared/Models/Category.cs +++ b/Billing.Shared/Models/Category.cs @@ -1,5 +1,6 @@ using SQLite; - +using System; + namespace Billing.Models { public class Category : IIdItem @@ -14,6 +15,8 @@ namespace Billing.Models public string Name { get; set; } public long TintColor { get; set; } = TRANSPARENT_COLOR; public int? ParentId { get; set; } + public DateTime? LastUsed { get; set; } + public int? LastAccountId { get; set; } } public enum CategoryType diff --git a/Billing.Shared/Views/AddBillPage.xaml.cs b/Billing.Shared/Views/AddBillPage.xaml.cs index 0bd0ddb..01b6ce8 100644 --- a/Billing.Shared/Views/AddBillPage.xaml.cs +++ b/Billing.Shared/Views/AddBillPage.xaml.cs @@ -170,6 +170,9 @@ namespace Billing.Views Store = Store, Note = Note }); + + category.LastAccountId = walletId; + category.LastUsed = DateTime.Now; } } @@ -190,6 +193,14 @@ namespace Billing.Views private void CategorySelectPage_Tapped(object sender, UICategory e) { categoryId = e.Category.Id; + if (e.Category.LastAccountId != null) + { + var wallet = App.Accounts.FirstOrDefault(a => a.Id == e.Category.LastAccountId.Value); + if (wallet != null) + { + SetValue(WalletNameProperty, wallet.Name); + } + } SetValue(CategoryNameProperty, e.Name); }