コード例 #1
0
        public async Task <PaytopiaItemModel> GetItem(PaytopiaItemType itemType)
        {
            var cacheResult = await CacheService.GetOrSetHybridAsync(CacheKey.PaytopiaItem(itemType), TimeSpan.FromMinutes(10), async() =>
            {
                using (var context = DataContextFactory.CreateReadOnlyContext())
                {
                    var item = await context.PaytopiaItems
                               .AsNoTracking()
                               .Where(x => x.Type == itemType && x.IsEnabled)
                               .Select(x => new PaytopiaItemModel
                    {
                        Id          = x.Id,
                        Name        = x.Name,
                        Description = x.Description,
                        Price       = x.Price,
                        Type        = x.Type,
                        Category    = x.Category,
                        CurrencyId  = x.CurrencyId
                    }).FirstOrDefaultNoLockAsync().ConfigureAwait(false);

                    var currency = await CurrencyReader.GetCurrency(item.CurrencyId).ConfigureAwait(false);
                    if (currency != null)
                    {
                        item.Symbol = currency.Symbol;
                    }
                    return(item);
                }
            }).ConfigureAwait(false);

            return(cacheResult);
        }
コード例 #2
0
 public static string PaytopiaItem(PaytopiaItemType itemType)
 {
     return($"paytopiaitem-{itemType}");
 }