public Task <List <CurrencyModel> > HandleAsync(ListAllCurrency query) { using (ReadModelContext db = readModelContextFactory.Create()) { return(db.Currencies .WhereUserKey(query.UserKey) .Where(c => !c.IsDeleted) .Select(c => new CurrencyModel(c.UniqueCode, c.Symbol, c.IsDefault)) .ToListAsync()); } }
private async Task EnsureListAsync(HttpQueryDispatcher.Next next, ListAllCurrency listAll) { if (models.Count == 0) { if (listAllTask == null) { listAllTask = LoadAllAsync(listAll, next); } await listAllTask; listAllTask = null; } }
private async Task LoadAllAsync(ListAllCurrency listAll, HttpQueryDispatcher.Next next) { models.Clear(); if (!network.IsOnline) { var items = await localStorage.LoadAsync(); if (items != null) { models.AddRange(items); return; } } models.AddRange((List <CurrencyModel>) await next(listAll)); await localStorage.SaveAsync(models); }
private async Task LoadAllAsync(HttpQueryDispatcher dispatcher, HttpQueryDispatcher.Next next, ListAllCurrency listAll) { models.Clear(); if (!serverConnection.IsAvailable) { var items = await localStorage.LoadAsync(); if (items != null) { models.AddRange(items); return; } } if (dispatcher != null) { models.AddRange(await dispatcher.QueryAsync(listAll)); } else { models.AddRange((List <CurrencyModel>) await next(listAll)); } await localStorage.SaveAsync(models); }
private async Task LoadAllAsync(ListAllCurrency listAll, HttpQueryDispatcher.Next next) { models.Clear(); models.AddRange((List <CurrencyModel>) await next(listAll)); }
private async Task EnsureListAsync(HttpQueryDispatcher dispatcher, HttpQueryDispatcher.Next next, ListAllCurrency listAll) { if (models.Count == 0) { if (listAllTask == null) { listAllTask = LoadAllAsync(dispatcher, next, listAll); } try { await listAllTask; } finally { listAllTask = null; } } }