public Word MapWord(Word word, WordUpdate updateRequest) { word.CategoryId = updateRequest.CategoryId; word.Value = updateRequest.Value; return(word); }
public void InvokeWordUpdate(WordUpdate wordUpdate) { if (wordUpdateEvent != null) { wordUpdateEvent.Invoke(wordUpdate); } }
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"); } }
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 }); }
void UpdateFilledBar(WordUpdate wordUpdate) { this.bar.fillAmount = wordUpdate.WordTypedProgress; }
public async Task <WordUpdateResult> UpdateWord([FromBody] WordUpdate request) { return(await wordUpdater.UpdateWord(request)); }