public void CreateCatWord(WordData model, int wordId, out int catWordId) { var catWord = new CategorizedWord { WordId = wordId, CategoryId = model.CategoryId, UserName = _user.Identity.Name }; _context.CategorizedWords.Add(catWord); _context.SaveChanges(); catWordId = catWord.Id; }
private void FillModel(WordData model, Language language, List <Word> words, CategorizedWord catWord) { var category = _context.Categories.Find(catWord.CategoryId); var translations = _context.Translations.Where(t => t.CategorizedWordId == catWord.Id).ToList(); var helper = new WordDataHelper(_context, _accessor); model.WordId = catWord.WordId; model.Word = words.Find(w => w.Id == catWord.WordId).ThisWord; model.LanguageId = language.Id; model.Language = language.Name; model.CategoryId = catWord.CategoryId; model.Category = catWord.Category.Name; model.CatWordId = catWord.Id; model.TranslationIds = helper.TranslationIdsToString(translations); model.Translation = helper.TranslationsToString(translations); }