public IAccountModel CreateNewAccount() { var entity = new Account { Currency = CurrencyBase, Type = AccountType.Card }; return(new AccountModel(entity, _service, isNew: true)); }
public async Task UpdateAccounts(CancellationToken token) { if (_service.IsAuthorized) { var accounts = await _service.GetAccounts(true, token); if (accounts != null) { foreach (var receivedAccount in accounts) { var entity = new Account { Id = receivedAccount.Id, Balance = receivedAccount.Balance, Currency = CurrencyHelper.GetSymbol(receivedAccount.Currency), Title = receivedAccount.Title, Type = receivedAccount.Type, IsArchived = receivedAccount.IsArchived, IsDeleted = receivedAccount.IsDeleted, IsSynchronized = true }; if (await _repository.HaveAccount(receivedAccount.Id, token)) { await _repository.UpdateAccount(entity, token); } else { await _repository.CreateAccount(entity, token); } } } } Accounts.Clear(); foreach (var account in await _repository.GetAccounts(token)) { Accounts.Add(new AccountModel(account, _service)); } TotalAmount = Accounts.Where(a => !a.IsArchived).Sum(a => a.Balance); var user = await _repository.GetUser(token); CurrencyBase = user.CurrencyBase; }