コード例 #1
0
ファイル: VocabularyHub.cs プロジェクト: EAlhovik/Vocabulary
        public void UpdateWord(Word word)
        {
            var uow = new VocabularyUow(new VocabularyDbContext());
            IVocabularyService vocabularyService = new VocabularyService(uow);

            try
            {
                vocabularyService.UpdateWord(word);
                Clients.PublishUpdated("Успех!");
            }
            catch(Exception)
            {
                Clients.PublishUpdated("Ошибка");

            }
        }
コード例 #2
0
        /// <summary>
        /// Updates the word.
        /// </summary>
        /// <param name="word">The word.</param>
        public void UpdateWord(Word word)
        {
            if(word.IsNew())
            {
                vocabularyUow.Words.InsertOrUpdate(word, true);
            }
            else
            {
                var dbWord = vocabularyUow.Words.GetById(word.Id);
                vocabularyUow.Words.InsertOrUpdate(dbWord, true);
                dbWord.Key = word.Key;
                dbWord.Theme = word.Theme;
                dbWord.Description = word.Description;
            }

            vocabularyUow.Commit();
        }
コード例 #3
0
 /// <summary>
 /// Deletes the word.
 /// </summary>
 /// <param name="word">The word.</param>
 public void DeleteWord(Word word)
 {
     vocabularyUow.Words.Delete(word);
     vocabularyUow.Commit();
 }