public WordTranslationModel Map(WordTranslation WordTranslation)
 {
     WordTranslationModel wordTranslationModel = new WordTranslationModel();
     wordTranslationModel.Id = WordTranslation.Id;
     wordTranslationModel.TranslationWord = WordTranslation.TranslationWord.Value;
     return wordTranslationModel;
 }
 public WordTranslationModel Map(WordTranslation WordTranslation)
 {
     WordTranslationModel wordTranslationModel = new WordTranslationModel();
     wordTranslationModel.Id = WordTranslation.Id;
     wordTranslationModel.OriginalWordDesc = WordTranslation.OriginalWord.Description;
     wordTranslationModel.TranslationWord = WordTranslation.TranslationWord.Value;
     return wordTranslationModel;
 }
 public int Add(WordTranslation wordTranslation)
 {
     using (var context = new WorldOfWordsDatabaseContext())
     {
         context.WordTranslations.Add(wordTranslation);
         context.SaveChanges();
         return wordTranslation.Id;
     }
 }
 public WordTranslationImportModel MapToImportModel(WordTranslation wordTranslation)
 {
     return new WordTranslationImportModel()
     {
         OriginalWord = wordTranslation.OriginalWord.Value,
         OriginalWordId = wordTranslation.OriginalWordId,
         Transcription = wordTranslation.OriginalWord.Transcription,
         Description = wordTranslation.OriginalWord.Description,
         TranslationWord = wordTranslation.TranslationWord.Value,
         TranslationWordId = wordTranslation.TranslationWordId
     };
 }
 public WordTranslationModel Map(WordTranslation wordTranslation)
 {
     if (wordTranslation == null)
     {
         throw new ArgumentNullException("wordTranslation");
     }
     return new WordTranslationModel()
     {
         Id = wordTranslation.Id,
         OriginalWord = wordTranslation.OriginalWord.Value,
         TranslationWord = wordTranslation.TranslationWord.Value
     };
 }
 public int Add(WordTranslation wordTranslation)
 {
     using (var uow = _unitOfWorkFactory.GetUnitOfWork())
     {
         var ids = wordTranslation.Tags.Select(tag => tag.Id);
         wordTranslation.Tags = uow.TagRepository.GetAll().Where(t => ids.Contains(t.Id)).ToList();
         uow.WordTranslationRepository.AddOrUpdate(wordTranslation);
         uow.Save();
         return wordTranslation.Id;
     }
     //using (var context = new WorldOfWordsDatabaseContext())
     //{
     //    context.WordTranslations.Add(wordTranslation);
     //    context.SaveChanges();
     //    return wordTranslation.Id;
     //}
 }
 public void Map_WordTranslationAndTrainingWordTranslationModelAreEqual()
 {
     var initial = new WordTranslation()
     {
         OriginalWord = new Word
         {
             Value = "Sunday"
         },
         TranslationWord = new Word
         {
             Value = "неділя"
         }
     };
     var expected = new WordTranslationModel()
     {
         OriginalWord = "Sunday",
         TranslationWord = "неділя"
     };
     var actual = (new TrainingWordTranslationMapper()).Map(initial);
     Assert.AreEqual(expected.OriginalWord,actual.OriginalWord);
     Assert.AreEqual(expected.TranslationWord, actual.TranslationWord);
 }
 public int Add(WordTranslation wordTranslation)
 {
     using (var uow = unitOfWorkFactory.GetUnitOfWork())
     {
         //var ids = wordTranslation.Tags.Select(tag => tag.Id);
         //wordTranslation.Tags = uow.TagRepository.GetAll().Where(t => ids.Contains(t.Id)).ToList();
         uow.WordTranslationRepository.AddOrUpdate(wordTranslation);
         uow.Save();
         return wordTranslation.Id;
     }
 }