Пример #1
0
        public async Task AddWordListItemDefinitionAsync(AddWordListDefinitionCommandModel command)
        {
            var wordDefinition = _mapper.Map <WordDefinitionEntity>(command.WordDefinition);
            var entity         = await _mongoRepository.FindAsync(x => x.UserId == command.UserId && x.Word == command.Word);

            if (entity == null)
            {
                entity = new WordListItemEntity
                {
                    UserId = command.UserId,
                    Word   = command.Word,
                };
            }

            entity.WordDefinitions ??= new List <WordDefinitionEntity>();

            if (!entity.WordDefinitions.Exists(x => x.Definition == command.WordDefinition.Definition))
            {
                entity.WordDefinitions.Add(wordDefinition);

                await _mongoRepository.AddOrUpdateAsync(entity);
            }
        }
Пример #2
0
 public Task AddDefinitionAsync(AddWordListDefinitionCommandModel command)
 {
     return(_repository.AddWordListItemDefinitionAsync(command));
 }