public void AddWord(WordsCategory word) { var editedWord = entity.Words.Find(word.ID); if (editedWord == null) { if (word.WordsGroup == null) { int lastID = lastSynonymGroupID(); lastID = lastID + 1; string LastID = lastID.ToString(); word.WordsGroup = LastID; } entity.Words.Add(word); } else { addPoints(word.PostedBy); editedWord.Word = word.Word; editedWord.CategoryID = word.CategoryID; editedWord.WordsGroup = word.WordsGroup; editedWord.Available = word.Available; editedWord.PostedBy = word.PostedBy; } entity.SaveChanges(); }
public void RemoveWord(WordsCategory word) { var Word = new WordsCategory { ID = word.ID }; entity.Words.Attach(Word); entity.Words.Remove(Word); entity.SaveChanges(); }