예제 #1
0
        public Word MapWord(Word word, WordUpdate updateRequest)
        {
            word.CategoryId = updateRequest.CategoryId;
            word.Value      = updateRequest.Value;

            return(word);
        }
예제 #2
0
 public void InvokeWordUpdate(WordUpdate wordUpdate)
 {
     if (wordUpdateEvent != null)
     {
         wordUpdateEvent.Invoke(wordUpdate);
     }
 }
예제 #3
0
 public async Task ValidateUpdateModel(WordUpdate model)
 {
     if (model == null)
     {
         throw new ValidationFailedException("No data provided to perform update");
     }
     if (model.Id <= 0)
     {
         throw new ValidationFailedException("Must specify word id");
     }
     if (string.IsNullOrEmpty(model.Value))
     {
         throw new ValidationFailedException("Word must have a value");
     }
     if (await WordValueExists(model.Id, model.Id, model.Value))
     {
         throw new ValidationFailedException("Word already exists");
     }
 }
예제 #4
0
        public async Task <WordUpdateResult> UpdateWord(WordUpdate model)
        {
            await validator.ValidateUpdateModel(model);

            var toUpdate = await context.Words.SingleOrDefaultAsync(x => x.Id == model.Id);

            if (toUpdate == null)
            {
                throw new ArgumentException($"Can't find word with id {model.Id}");
            }

            toUpdate = mapper.MapWord(toUpdate, model);

            await context.SaveChangesAsync();

            var wordModel = await wordProvider.GetWord(model.Id);

            return(new WordUpdateResult()
            {
                Word = wordModel
            });
        }
예제 #5
0
 void UpdateFilledBar(WordUpdate wordUpdate)
 {
     this.bar.fillAmount = wordUpdate.WordTypedProgress;
 }
예제 #6
0
 public async Task <WordUpdateResult> UpdateWord([FromBody] WordUpdate request)
 {
     return(await wordUpdater.UpdateWord(request));
 }