add: last used category
This commit is contained in:
		@@ -1,4 +1,5 @@
 | 
				
			|||||||
using SQLite;
 | 
					using SQLite;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Billing.Models
 | 
					namespace Billing.Models
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -14,6 +15,8 @@ namespace Billing.Models
 | 
				
			|||||||
        public string Name { get; set; }
 | 
					        public string Name { get; set; }
 | 
				
			||||||
        public long TintColor { get; set; } = TRANSPARENT_COLOR;
 | 
					        public long TintColor { get; set; } = TRANSPARENT_COLOR;
 | 
				
			||||||
        public int? ParentId { get; set; }
 | 
					        public int? ParentId { get; set; }
 | 
				
			||||||
 | 
					        public DateTime? LastUsed { get; set; }
 | 
				
			||||||
 | 
					        public int? LastAccountId { get; set; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public enum CategoryType
 | 
					    public enum CategoryType
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -170,6 +170,9 @@ namespace Billing.Views
 | 
				
			|||||||
                    Store = Store,
 | 
					                    Store = Store,
 | 
				
			||||||
                    Note = Note
 | 
					                    Note = Note
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                category.LastAccountId = walletId;
 | 
				
			||||||
 | 
					                category.LastUsed = DateTime.Now;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -190,6 +193,14 @@ namespace Billing.Views
 | 
				
			|||||||
        private void CategorySelectPage_Tapped(object sender, UICategory e)
 | 
					        private void CategorySelectPage_Tapped(object sender, UICategory e)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            categoryId = e.Category.Id;
 | 
					            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);
 | 
					            SetValue(CategoryNameProperty, e.Name);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user