Esempio n. 1
0
 public static void DeleteWord(int wordId)
 {
     WordBinEntities db = new WordBinEntities();
     var word = db.Words.Where(x => x.Id.Equals(wordId)).FirstOrDefault();
     db.Words.DeleteObject(word);
     db.SaveChanges();
 }
Esempio n. 2
0
 public static void RenameDictionary(int dictionaryId, string newName)
 {
     WordBinEntities db = new WordBinEntities();
     var dict = db.Dictionaries.Where(x => x.Id.Equals(dictionaryId)).FirstOrDefault();
     dict.Name = newName;
     db.SaveChanges();
 }
Esempio n. 3
0
 public static void AddDictionary(string name, string username)
 {
     WordBinEntities db = new WordBinEntities();
     var user = db.Users.Where(x => x.UserName.Equals(username)).FirstOrDefault();
     db.Dictionaries.AddObject(new Dictionary()
     {
         Name = name,
         UserId = user.UserId
     });
     db.SaveChanges();
 }
Esempio n. 4
0
 public static void AddWord(string word, string definition, string example, int dictionaryId)
 {
     WordBinEntities db = new WordBinEntities();
     db.Words.AddObject(new Word()
     {
         Word1 = word,
         Definition = definition,
         Example = example,
         DictionaryId = dictionaryId
     });
     db.SaveChanges();
 }
Esempio n. 5
0
 public static void DeleteDictionary(int dictionaryId)
 {
     WordBinEntities db = new WordBinEntities();
     var wordsForDictionary = db.Words.Where(w => w.DictionaryId.Equals(dictionaryId));
     foreach (var word in wordsForDictionary)
     {
         db.DeleteObject(word);
     }
     var dict = db.Dictionaries.Where(x => x.Id.Equals(dictionaryId)).FirstOrDefault();
     db.DeleteObject(dict);
     db.SaveChanges();
 }
Esempio n. 6
0
 public static void ModifyWord(int wordId, string newWord, string newDefinition, string newExample)
 {
     WordBinEntities db = new WordBinEntities();
     var word = db.Words.Where(x => x.Id.Equals(wordId)).FirstOrDefault();
     word.Word1 = newWord;
     word.Definition = newDefinition;
     if (newExample == null)
     {
         word.Example = string.Empty;
     }
     else
     {
         word.Example = newExample;
     }
     db.SaveChanges();
 }