예제 #1
0
        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);
            }
        }
예제 #2
0
        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();
            }
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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();
            }
        }