public async Task <PlayerBasket> AddToBasket(string playerId, Tournament tournament)
        {
            var basket = new PlayerBasket();

            var item = await _cache.GetStringAsync(playerId);

            if (!string.IsNullOrEmpty(item))
            {
                basket = item.Deserialize <PlayerBasket>();
            }

            basket.AddItem(tournament);

            await _cache.SetStringAsync(playerId, basket.ToJson(), new DistributedCacheEntryOptions()
            {
                AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(1)
            });

            return((await _cache.GetStringAsync(playerId)).Deserialize <PlayerBasket>());
        }
Exemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     playerBasket = FindObjectOfType <PlayerBasket>();
 }