Exemplo n.º 1
0
        public WordSuiteEditModel MapForEdit(WordSuite wordSuite)
        {
            if (wordSuite == null)
            {
                throw new ArgumentNullException("wordSuite");
            }
            WordSuiteEditModel model = new WordSuiteEditModel();

            model.Id                    = wordSuite.Id;
            model.Name                  = wordSuite.Name;
            model.Language              = wordSuite.Language.Name;
            model.LanguageId            = wordSuite.LanguageId;
            model.TranslationLanguageId = wordSuite.TranslationLanguageId;
            if (wordSuite.TranslationLanguage != null)
            {
                model.TranslationLanguageName = wordSuite.TranslationLanguage.Name;
            }
            else
            {
                model.TranslationLanguageName = "";
            }
            model.PrototypeId         = wordSuite.PrototypeId;
            model.Threshold           = wordSuite.Threshold;
            model.QuizResponseTime    = wordSuite.QuizResponseTime;
            model.ProhibitedQuizzesId = wordSuite.ProhibitedQuizzes.Select(q => q.Id).ToList();
            return(model);
        }
Exemplo n.º 2
0
 public WordSuite Map(WordSuiteEditModel wordSuite)
 {
     if (wordSuite == null)
     {
         throw new ArgumentNullException("wordSuite");
     }
     return new WordSuite()
     {
         Id = wordSuite.Id,
         Name = wordSuite.Name,
         LanguageId = wordSuite.LanguageId,
         Threshold = wordSuite.Threshold,
         QuizResponseTime = wordSuite.QuizResponseTime
     };
 }
Exemplo n.º 3
0
 public WordSuite Map(WordSuiteEditModel wordSuite)
 {
     if (wordSuite == null)
     {
         throw new ArgumentNullException("wordSuite");
     }
     return(new WordSuite()
     {
         Id = wordSuite.Id,
         Name = wordSuite.Name,
         LanguageId = wordSuite.LanguageId,
         Threshold = wordSuite.Threshold,
         QuizResponseTime = wordSuite.QuizResponseTime
     });
 }
Exemplo n.º 4
0
        public IHttpActionResult Post(WordSuiteEditModel wordSuite)
        {
            if (wordSuite == null)
            {
                throw new ArgumentNullException("wordSuite", "WordSuite can't be null");
            }

            if (wordSuite.IsBasicInfoChanged)
            {
                if (!wordSuiteService.Update(wordSuiteMapper.Map(wordSuite)))
                {
                    return BadRequest("Failed to edit WordSuite");
                }
            }

            if (wordSuite.WordTranslationsToDeleteIdRange != null)
            {
                if (wordSuite.WordTranslationsToDeleteIdRange.Count > 0)
                {
                    if (!wordProgressService.RemoveRange(wordProgressMapper.MapRange(wordSuite.Id, wordSuite.WordTranslationsToDeleteIdRange)))
                    {
                        return BadRequest("Failed to remove WordTranslations");
                    }
                }
            }

            if (wordSuite.WordTranslationsToAddIdRange != null)
            {
                if (wordSuite.WordTranslationsToAddIdRange.Count > 0)
                {
                    if (!wordProgressService.AddRange(wordProgressMapper.MapRange(wordSuite.Id, wordSuite.WordTranslationsToAddIdRange)))
                    {
                        return BadRequest("Failed to add WordTranslations");
                    }
                }
            }

            return Ok();
        }