internal bool CreateNewAccount() { this.Accounts.Remove(this.newAccountEntryViewModel); var accountModel = this.newAccountEntryViewModel.Model; decimal startingBalance; var hasStartingBalance = decimal.TryParse( this.newAccountEntryViewModel.StartingCashBalance, out startingBalance); var newModel = this.entityModel.CreateAccount( this.model.PortfolioId, accountModel.Name, accountModel.Description, accountModel.Currency, hasStartingBalance ? (decimal?)startingBalance : null); this.accounts.Add(new AccountEntryViewModel { Model = newModel }); this.Accounts.Remove(this.newAccountEntryViewModel); this.newAccountEntryViewModel = new NewAccountEntryViewModel(this.entityModel, this); this.accounts.Add(this.newAccountEntryViewModel); return(true); }
private void SetModel(int portfolioId) { this.model = this.entityModel.GetPorfolio(portfolioId); this.accounts.Clear(); var viewModels = from accountEntity in this.entityModel.Accounts where accountEntity.Portfolio.PortfolioId == portfolioId select new AccountEntryViewModel() { Model = accountEntity }; this.accounts.AddRange(viewModels); this.newAccountEntryViewModel = new NewAccountEntryViewModel(this.entityModel, this); this.accounts.Add(this.newAccountEntryViewModel); this.OnPropertyChanged(string.Empty); }