public int IncreasePassedCount(int userKey, int wordId) { using (VocabularyEntities context = new VocabularyEntities()) { StagedWord stagedWord = context.StagedWords.FirstOrDefault(x => x.UserKey == userKey && x.WordId == wordId); stagedWord.PassedCount++; context.SaveChanges(); return(stagedWord.PassedCount); } }
public void DeleteWordByGrade(int userKey, int grade) { using (VocabularyEntities context = new VocabularyEntities()) { List <StagedWord> list = (from x in context.StagedWords where x.UserKey == userKey && x.Word.Grade == grade select x).ToList(); context.StagedWords.RemoveRange(list); context.SaveChanges(); } }
public LastSelect GetLastSelect(int userKey, int grade) { using (VocabularyEntities context = new VocabularyEntities()) { LastSelect lastSelect = context.LastSelects.FirstOrDefault(x => x.UserKey == userKey && x.Grade == grade); if (lastSelect == null) { lastSelect = new LastSelect { UserKey = userKey, Grade = grade, WordId = context.Words.Where(x => x.Grade == grade).FirstOrDefault().WordId }; context.LastSelects.Add(lastSelect); context.SaveChanges(); return(lastSelect); } return(lastSelect); } }
public void SetLastSelect(int userKey, int grade, int wordId) { using (VocabularyEntities context = new VocabularyEntities()) { LastSelect lastSelect = context.LastSelects.FirstOrDefault(x => x.UserKey == userKey && x.Grade == grade); if (lastSelect != null) { lastSelect.WordId = wordId; } else { lastSelect = new LastSelect(); lastSelect.UserKey = userKey; lastSelect.Grade = grade; lastSelect.WordId = wordId; context.LastSelects.Add(lastSelect); } context.SaveChanges(); } }