public WordTranslation Map(WordTranslationImportModel wordTranslation)
 {
     return new WordTranslation()
     {
         OriginalWordId = wordTranslation.OriginalWordId,
         TranslationWordId = wordTranslation.TranslationWordId,
         OwnerId = wordTranslation.OwnerId
     };
 }
Esempio n. 2
0
 public WordTranslation Map(WordTranslationImportModel wordTranslation)
 {
     return(new WordTranslation()
     {
         OriginalWordId = wordTranslation.OriginalWordId,
         TranslationWordId = wordTranslation.TranslationWordId,
         OwnerId = wordTranslation.OwnerId
     });
 }
 public WordTranslation Map (WordTranslationImportModel wordTranslation, List<Tag> tags)
 {
     return new WordTranslation()
     {
         OriginalWordId = wordTranslation.OriginalWordId,
         TranslationWordId = wordTranslation.TranslationWordId,
         OwnerId = wordTranslation.OwnerId,
         //Tags = tags
     };
 }
 public WordTranslation Map(WordTranslationImportModel wordTranslation, List <Tag> tags)
 {
     return(new WordTranslation()
     {
         OriginalWordId = wordTranslation.OriginalWordId,
         TranslationWordId = wordTranslation.TranslationWordId,
         OwnerId = wordTranslation.OwnerId,
         Tags = tags
     });
 }
 public IHttpActionResult Post(WordTranslationImportModel wordtranslation)
 {
     if (wordtranslation == null)
         throw new ArgumentNullException("word translation model can't be empty");
     if(wordTranslationService.Exists(wordtranslation.OriginalWordId, wordtranslation.TranslationWordId)==0)
     {
         return Ok(wordTranslationService.Add(wordTranslationMapper.Map(wordtranslation)).ToString());
     }
     else
     {
         return BadRequest("Such wordtranslation exists");
     }
 }
 public async Task<int> AddAsync(WordTranslationImportModel wordTranslation)
 {
     using (var uow = unitOfWorkFactory.GetUnitOfWork())
     {
         WordTranslation wordToAdd = wordTranslationMapper.Map(wordTranslation);
         uow.WordTranslationRepository.AddOrUpdate(wordToAdd);
         await uow.SaveAsync();
         return wordToAdd.Id;
     }
 }
 public async Task<IHttpActionResult> Post(WordTranslationImportModel wordtranslation)
 {
     if (wordtranslation == null)
         throw new ArgumentNullException("word translation model can't be empty");
     if (wordTranslationService.Exists(wordtranslation.OriginalWordId, wordtranslation.TranslationWordId) == 0)
     {
         int res = await wordTranslationService.AddAsync(wordtranslation);
         return Ok(res.ToString());
     }
     else
     {
         return BadRequest("Such wordtranslation exists");
     }
 }