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); }
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); }
public List <Subject> GetSubjects() { List <Subject> subjects = new List <Subject>(); using (var context = new KartuvesDbContext()) { subjects = context.Subjects.Select(x => x).ToList(); } return(subjects); }
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); }
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); }
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(); } } }
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(); } } }
public virtual void CreateUser(string name) { if (!string.IsNullOrEmpty(name)) { using (var context = new KartuvesDbContext()) { context.Users.Add(new User { Name = name }); context.SaveChanges(); } } }
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); }