Exemple #1
0
        public List <WordPairComplexDTO> GetWordtest(int wordGroupId)
        {
            List <WordPairComplexDTO> wordList = new List <WordPairComplexDTO>();
            SynonymsView viewModel             = new SynonymsView();

            viewModel.FillViewModel(wordGroupId);

            string languageCode1 = "";
            string languageCode2 = "";

            foreach (var viewModelSynonym in viewModel.SortedSynonyms)
            {
                WordPairComplexDTO synonym = new WordPairComplexDTO {
                    Id = viewModelSynonym.Id
                };
                wordList.Add(synonym);
                foreach (var list in viewModelSynonym.SortedWordList)
                {
                    //Första ordets språk avgör för listan som bara har två språk. Språken är sorterade i bokstavsordning.
                    //Tveksam lösning, men gör appen enklare och funkar väl ok.. Det kan finnas mer än och mindre än två språk vilket inte appen hanterar så väl
                    if (languageCode1 == "")
                    {
                        languageCode1 = list.Value.Language.Code;
                    }
                    else if (languageCode2 == "" && list.Value.Language.Code != languageCode1)
                    {
                        languageCode2 = list.Value.Language.Code;
                    }

                    if (list.Value.Language.Code == languageCode1)
                    {
                        foreach (var word in list.Value.Words)
                        {
                            synonym.Word1.Add(new WordDTO {
                                Id = word.Id, Language = word.Language.Name, LanguageId = word.LanguageId, Text = word.Text
                            });
                        }
                    }
                    else if (list.Value.Language.Code == languageCode2)
                    {
                        foreach (var word in list.Value.Words)
                        {
                            synonym.Word2.Add(new WordDTO {
                                Id = word.Id, Language = word.Language.Name, LanguageId = word.LanguageId, Text = word.Text
                            });
                        }
                    }
                }
            }
            return(wordList);
        }
Exemple #2
0
        public ActionResult Index(int wordGroupId = 0)
        {
            if (wordGroupId == 0)
            {
                return(RedirectToAction("Index", "WordGroups"));
            }

            Session["WordGroupId"] = wordGroupId;
            SynonymsView viewModel = new SynonymsView();//FillViewModel();

            viewModel.FillViewModel(wordGroupId);
            ViewBag.LanguageId = new SelectList(db.Language, "Id", "Name");

            return(View(viewModel));
        }
Exemple #3
0
        public List <WordPairComplexDTO> GetWordtestComplex(int wordGroupId, string languageCode1, string languageCode2)
        {
            List <WordPairComplexDTO> wordList = new List <WordPairComplexDTO>();
            SynonymsView viewModel             = new SynonymsView();

            viewModel.FillViewModel(wordGroupId);

            foreach (var viewModelSynonym in viewModel.SortedSynonyms)
            {
                if (ShouldBeIncluded(viewModelSynonym, languageCode1, languageCode2))
                {
                    WordPairComplexDTO synonym = new WordPairComplexDTO {
                        Id = viewModelSynonym.Id
                    };
                    wordList.Add(synonym);
                    foreach (var list in viewModelSynonym.SortedWordList)
                    {
                        if (list.Value.Language.Code == languageCode1)
                        {
                            foreach (var word in list.Value.Words)
                            {
                                synonym.Word1.Add(new WordDTO {
                                    Id = word.Id, Language = word.Language.Name, LanguageId = word.LanguageId, Text = word.Text
                                });
                            }
                        }
                        else if (list.Value.Language.Code == languageCode2)
                        {
                            foreach (var word in list.Value.Words)
                            {
                                synonym.Word2.Add(new WordDTO {
                                    Id = word.Id, Language = word.Language.Name, LanguageId = word.LanguageId, Text = word.Text
                                });
                            }
                        }
                    }
                }
            }
            return(wordList);
        }