示例#1
0
 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());
     }
 }
示例#2
0
        private async Task EnsureListAsync(HttpQueryDispatcher.Next next, ListAllCurrency listAll)
        {
            if (models.Count == 0)
            {
                if (listAllTask == null)
                {
                    listAllTask = LoadAllAsync(listAll, next);
                }

                await listAllTask;
                listAllTask = null;
            }
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
 private async Task LoadAllAsync(ListAllCurrency listAll, HttpQueryDispatcher.Next next)
 {
     models.Clear();
     models.AddRange((List <CurrencyModel>) await next(listAll));
 }
示例#6
0
        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;
                }
            }
        }