示例#1
0
        public void UpdateAccount(Account account, string currency = null, string type = null, string name = null)
        {
            if (currency == null && type == null && name == null)
            {
                return;
            }
            var result = Data.Find(acc => acc == account);

            if (result != null)
            {
                if (currency != null)
                {
                    result.Currency.Type = currency;
                }
                if (type != null)
                {
                    result.Type = type;
                }
                if (name != null)
                {
                    result.Name = name;
                }
                AccountUpdated?.Invoke(this, new AccountManagerEventArgs(account, AccountManagerEventType.AccountUpdated));
            }
        }
        async void OnSave(object sender, EventArgs e)
        {
            var account = BindingContext as Account;

            if (String.IsNullOrWhiteSpace(account.Name))
            {
                await DisplayAlert("Error", "Please enter name for entry", "OK");

                return;
            }

            //Check if this is a new account or an edit of existing account
            if (account.Status == null)
            {
                AccountAdded?.Invoke(this, account);
            }
            else
            {
                AccountUpdated?.Invoke(this, account);
            }

            await Navigation.PopAsync();
        }