Esempio n. 1
0
        public ChoiceViewModel(choiceDto cd, string encryptedKey)
        {
            this.choiceSn     = cd.sn;
            this.choiceStr    = cd.choiceStr;
            this.comment      = cd.comment;
            this.betMoney     = cd.betMoneygti;
            this.betball      = Math.Round(this.betMoney / 10000, 2);
            this.Odds         = cd.Odds;
            this.betModel     = cd.betModel;
            this.dragonshort  = cd.dragonshort;
            this.encryptedKey = encryptedKey;
            var teams = new TeamsRepository().getImg(cd.choiceStr);

            if (teams != null)
            {
                this.teamimg = teams.imageURL;
            }

            if (cd.betMoney != null)
            {
                this.betMoneycount = cd.betMoney.Count();
            }
            else
            {
                this.betMoneycount = 0;
            }
        }
Esempio n. 2
0
        public bool addChoiceMoney(int choiceSn, double money)
        {
            bool isTure = true;

            lock (_cache)
            {
                if (_cache.Contains("GameList"))
                {
                    List <gameDto> gameList = new List <gameDto>();
                    gameList = _cache.Get("GameList") as List <gameDto>;
                    foreach (gameDto g in gameList)
                    {
                        foreach (topicDto t in g.topicList)
                        {
                            if (t.choiceList.Where(p => p.sn == choiceSn).Count() > 0)
                            {
                                choiceDto c = t.choiceList.Where(p => p.sn == choiceSn).FirstOrDefault();
                                c.betMoneygti += money;
                            }
                        }
                    }
                    CacheItemPolicy cacheItemPolicy = new CacheItemPolicy()
                    {
                        AbsoluteExpiration = DateTime.Now.AddDays(1)
                    };
                    _cache.Remove("GameList");
                    _cache.Add("GameList", gameList, cacheItemPolicy);
                }
                else
                {
                    isTure = false;
                }
            }

            return(isTure);
        }