public async Task <PhraseDto> Modify(UpdatePhraseDto phrase) { await DeleteRemovedPhrase(phrase.Text); var model = _mapper.Map <Phrase>(phrase); var source = await _dbContext.Phrases .Include(_ => _.Tags) .FirstAsync(_ => _.Id == phrase.Id); _dbContext.ModifyCollection(source.Tags, model.Tags); if (source.Text == model.Text) { source.UpdatedAt = DateTime.UtcNow; } else { source.Text = model.Text; } await SaveAndCheckUnique(phrase); return(_mapper.Map <PhraseDto>(source)); }
public Task <PhraseDto> ModifyPhrase(UpdatePhraseDto phrase) => _phrasesService.Modify(phrase);