コード例 #1
0
        public virtual async Task <TDto> CreateAsync(TDto dto, Action <string, string> AddErrorMessage)
        {
            if (!await ValidateCrUpDataAsync(dto, AddErrorMessage))
            {
                return(null);
            }

            TEntity entity        = _mappingService.DtoToEntity(dto);
            TEntity createdEntity = await _repository.CreateAsync(entity);

            if (createdEntity != null)
            {
                await _context.SaveChangesAsync();
            }

            createdEntity = await _repository.GetCompleteAsync(createdEntity.ID);

            return(_mappingService.EntityToDto(createdEntity));
        }