Esempio n. 1
0
        public virtual User ReadUserData(int userId)
        {
            User user = new User();

            using (var context = new KartuvesDbContext())
            {
                user = context.Users.FirstOrDefault(u => u.Id == userId);
            }
            return(user);
        }
Esempio n. 2
0
        public List <Word> GetWordsWithSubject(Subject subject)
        {
            List <Word> words = new List <Word>();

            using (var context = new KartuvesDbContext())
            {
                words = context.Words.Select(x => x).Where(name => name.SubjectId == subject.Id).ToList();
            }
            return(words);
        }
Esempio n. 3
0
        public List <Subject> GetSubjects()
        {
            List <Subject> subjects = new List <Subject>();

            using (var context = new KartuvesDbContext())
            {
                subjects = context.Subjects.Select(x => x).ToList();
            }
            return(subjects);
        }
Esempio n. 4
0
        public virtual void IncreaseIncorrectCount(string word)
        {
            using (var context = new KartuvesDbContext())
            {
                var inc = context.Words.FirstOrDefault(x => x.Name == word);
                inc.WordNotGuessedCount++;

                context.SaveChanges();
            }
        }
        public virtual List <ScoreBoard> GetAll()
        {
            List <ScoreBoard> sb = new List <ScoreBoard>();

            using (var context = new KartuvesDbContext())
            {
                sb = context.ScoreBoards.Select(x => x).ToList();
            }
            return(sb);
        }
        public virtual List <ScoreBoard> GetUserScoreBoards(string user)
        {
            List <ScoreBoard> sb = new List <ScoreBoard>();

            using (var context = new KartuvesDbContext())
            {
                sb = context.ScoreBoards.Select(x => x).Where(u => u.User.Name == user).ToList();
            }
            return(sb);
        }
Esempio n. 7
0
        public virtual List <User> ReadAllUsersData()
        {
            List <User> users = new List <User>();

            using (var context = new KartuvesDbContext())
            {
                users = context.Users.Select(x => x).ToList();

                context.SaveChanges();
            }
            return(users);
        }
Esempio n. 8
0
        public virtual void UpdateUser(User user, Word word, ScoreBoard scoreBoard)
        {
            using (var context = new KartuvesDbContext())
            {
                user = context.Users.FirstOrDefault(u => user.Id == u.Id);

                if (user != null && scoreBoard != null)
                {
                    user.ScoreBoards.Add(scoreBoard);
                    context.SaveChanges();
                }
            }
        }
Esempio n. 9
0
        public virtual void DeleteUser(int userId)
        {
            using (var context = new KartuvesDbContext())
            {
                var user = context.Users.FirstOrDefault(x => x.Id == userId);

                if (user != null)
                {
                    context.Users.Remove(user);

                    context.SaveChanges();
                }
            }
        }
Esempio n. 10
0
        public virtual void CreateUser(string name)
        {
            if (!string.IsNullOrEmpty(name))
            {
                using (var context = new KartuvesDbContext())
                {
                    context.Users.Add(new User {
                        Name = name
                    });

                    context.SaveChanges();
                }
            }
        }
Esempio n. 11
0
        public virtual ScoreBoard CreateScoreBoard(User user, Word word, int guessCount, bool isCorrect)
        {
            ScoreBoard sb = new ScoreBoard()
            {
                User        = user,
                Word        = word,
                WordToGuess = word.Name,
                Time        = DateTime.UtcNow,
                GuessCount  = guessCount,
                IsCorrect   = isCorrect
            };

            using (var context = new KartuvesDbContext())
            {
                context.ScoreBoards.Add(sb);
                context.SaveChanges();
            }

            return(sb);
        }