Exemple #1
0
        public virtual async Task <TDto> Create(TDto entityDto, bool index = true)
        {
            var entity           = _mapper.Map <T>(entityDto);
            var validationErrors = await ValidateCreate(entity);

            if (validationErrors?.Count > 0)
            {
                throw new CoreException(validationErrors);
            }
            _dbSet.AddObject(entity);
            await _dbContext.SaveChangesAsync();

            var resultDto = _mapper.Map <TDto>(entity);

            if (index)
            {
                await _esClient.IndexAsync(resultDto);
            }
            return(resultDto);
        }