Пример #1
0
        public int GetScore(string catId)
        {
            int score = -1;

            using (var db = new CatContext())
            {
                var cat = db.Cats.SingleOrDefault(c => c.Id == catId);
                if (cat != null)
                {
                    score = cat.Score;
                }
            }
            return(score);
        }
Пример #2
0
        public bool SetVote(string catId)
        {
            bool ok = false;

            using (var db = new CatContext())
            {
                var cat = db.Cats.SingleOrDefault(c => c.Id == catId);
                if (cat != null)
                {
                    cat.Score += 1;
                    db.SaveChanges();
                    ok = true;
                }
            }
            return(ok);
        }