コード例 #1
0
        private void LoadLearningStatus()
        {
            //Learned
            var wordRepository = new WordRepository();

            allItems = wordRepository.GetAll();
            Learned  = (allItems == null || allItems.Count == 0) ? "0 word" : (allItems.Count + " words");

            //Remembered
            rememberItems = allItems.Where(x => x.NRepetition == 3).ToList();
            Remembered    = (rememberItems == null || rememberItems.Count == 0) ? "0 word" : (rememberItems.Count + " words");

            //Deep remembered
            deepRememberItems = allItems.Where(x => x.NRepetition > 3).ToList();
            DeepRemembered    = (deepRememberItems == null || deepRememberItems.Count == 0) ? "0 word" : (deepRememberItems.Count + " words");

            //Not remember
            notRememberItems = allItems.Where(x => x.NRepetition < 3).ToList();
            NotRemembered    = (notRememberItems == null || notRememberItems.Count == 0) ? "0 word" : (notRememberItems.Count + " words");
        }
コード例 #2
0
        public void LoadData()
        {
            cellList = new List <LexiconItemViewModel> ();
            if (cellList == null)
            {
                cellList = new List <LexiconItemViewModel> ();
            }
            else if (cellList.Count > 0)
            {
                cellList.Clear();
            }

            //Get data from database (Sqlite)
            var wordRepository = new WordRepository();
            var items          = wordRepository.GetAll();

            foreach (var word in items)
            {
                var item = new LexiconItemViewModel()
                {
                    NewWord       = word.Word,
                    WordMeaning   = word.Meaning,
                    Note          = word.Note,
                    Example       = word.Example,
                    WordFormation = word.WordFormation,
                    ClientId      = word.ClientId,
                    Index         = items.IndexOf(word) + 1,
                    Collocation   = word.Collocation,
                    Synonym       = word.Synonym,
                    Antonym       = word.Antonym,
                    WordType      = word.WordType
                };

                cellList.Add(item);
            }
            LoadData(cellList);
        }
コード例 #3
0
        public void LoadData(bool today = true)
        {
            var wordRepository = new WordRepository();

            learningWords = new List <WordModel> ();
            if (today)
            {
                SmartLearningApplication.Instance.ShowWaitDialog();
                learningMode = LearningMode.SupperMemo;
                wordRepository.GetTodayLearningWordsAsync(CallBack);
            }
            else
            {
                var items = new List <WordModel> ();

                if (trainingMode == TrainingMode.Random)
                {
                    items = wordRepository.GetAll().OrderBy(x => Guid.NewGuid()).Take(5).ToList();
                }
                else if (trainingMode == TrainingMode.Today)
                {
                    items = wordRepository.GetItemsFromTo(DateTime.Now.Date, DateTime.Now.Date);
                }
                else if (trainingMode == TrainingMode.Yesterday)
                {
                    items = wordRepository.GetItemsFromTo(DateTime.Now.Date.AddDays(-1), DateTime.Now.Date);
                }

                foreach (var word in items)
                {
                    learningWords.Add(word);
                    learningMode = LearningMode.SelfTraning;
                }
            }

            SetupUI();
        }
コード例 #4
0
 public WhenInitializingData()
 {
     _records = WordRepository.GetAll().Result;
 }
コード例 #5
0
ファイル: WordsController.cs プロジェクト: Dark1498/TestTask
 // GET: api/Words
 public IEnumerable <Word> Get()
 {
     return(repository.GetAll());
 }
コード例 #6
0
ファイル: Program.cs プロジェクト: OmnixTry/English-trainer
        static void Main(string[] args)
        {
            IVocabularyUnitOfWork unitOfWork = new EFVocabularyUnitOfWork(new EnglishTrainer.DAL.EF.VocabularyContext());

            WordRepository  wordRepo        = (WordRepository)unitOfWork.Words;
            TopicRepository topicRepository = (TopicRepository)unitOfWork.Topics;

            /*
             * User user = new User() { NickName = "Test" };
             *
             * Word word1 = new Word() { EnglshTranslation = "Color", UkrainianTranslation = "Колір" };
             * Word word2 = new Word() { EnglshTranslation = "House", UkrainianTranslation = "Будинок" };
             * Word word3 = new Word() { EnglshTranslation = "Door", UkrainianTranslation = "Двері" };
             * Topic topic = new Topic { Name = "Starter2", Words = new List<Word>() { word1, word2, word3}, User = user };
             * word1.Topic = topic;
             * word2.Topic = topic;
             * word3.Topic = topic;
             * wordRepo.Create(word1);
             * wordRepo.Create(word2);
             * wordRepo.Create(word3);
             *
             *
             * topicRepository.Create(topic);
             * unitOfWork.Save();
             */

            foreach (Word word in wordRepo.GetAll())
            {
                Console.WriteLine("{0}, {1}, {2}, {3}", word.Id, word.EnglshTranslation, word.UkrainianTranslation, word.Topic.Id);
            }


            ITopicService topicService = new TopicService(unitOfWork, new Checker());

            foreach (TopicDTO item in topicService.GetTopics())
            {
                Console.WriteLine("{0}, {1}\n", item.Id, item.Name);
            }

            Console.WriteLine("get topic with id 1\n" +
                              "{0}\n", topicService.GetEngQuestoins(1).First().Queston);
            Console.WriteLine("get topic with id 1\n" +
                              "{0}\n", topicService.GetUkrQuestoins(1).First().Queston);

            var res = topicService.Check(new List <AnswerDTO>()
            {
                new AnswerDTO()
                {
                    Id = 1, Answer = "Color", Language = Language.English, TopicId = 1
                },
                new AnswerDTO()
                {
                    Id = 2, Answer = "House", Language = Language.English, TopicId = 1
                },
                new AnswerDTO()
                {
                    Id = 3, Answer = "e", Language = Language.English, TopicId = 1
                },
            });

            foreach (var item in res)
            {
                Console.WriteLine("{0} {1}", item.IsCorrect, item.Answer);
            }

            List <WordDTO> wordsToInsert = new List <WordDTO>()
            {
                new WordDTO("Book", "Книга"),
                new WordDTO("Thread", "Нитка"),
                new WordDTO("Computer", "Комп'ютер"),
                new WordDTO("Paper", "Папір")
            };

            topicService.AddTopic(wordsToInsert, "starter3", 1);
        }