public int Save(KeywordModel model) { Keyword keyword = new Keyword { Name = model.Name }; keywordRepository.Save(keyword); return(keyword.Id); }
private static Keyword register(string name, int level) { Keyword keyword = new Keyword { Name = name, Level = level, CreateTime = DateTime.Now }; KeywordRepository keywordRepository = new KeywordRepository(Helper.GetDbContext()); keywordRepository.Save(keyword); return(keyword); }
public void SaveKeywords(string needSaveKeyword) { IList <Keyword> keywords = new Keyword().GetKeyWordslist(needSaveKeyword); foreach (var item in keywords) { keywordEntity = keywordRepository.GetByKeyword(item); if (keywordEntity == null) { keywordEntity = new Keyword().AddNewKeyword(item); keywordRepository.Save(keywordEntity); } else { keywordEntity = keywordEntity.AddUsed(item); keywordRepository.UpdateKeywordUsed(keywordEntity); } } }
public int Publish(NewModel model) { Article article = new Article { Title = model.Title, Body = model.Body, Author = GetCurrentUser(false), Digest = model.Digest }; article.Belong = serieRepository.Find(model.Belong.Id); IList <string> strKeywords = keywordRepository.splitKeywords(model.Keywords); IList <Keyword> objKeywords = new List <Keyword>(); Keyword keyword; foreach (var item in strKeywords) { if (keywordRepository.GetByName(item) == null) { Keyword newKeyword = new Keyword { Name = item }; keywordRepository.Save(newKeyword); keyword = newKeyword; } else { keyword = keywordRepository.GetByName(item); } objKeywords.Add(keyword); } article.Keywords = objKeywords; articleRepository.Save(article); return(article.Id); }