Пример #1
0
        public async Task <NotifikatItemDTO> Handle(CreateNotifikationCommand request, CancellationToken cancellationToken)
        {
            var notifikationEntity = _mapper.Map <NotifikationEntity>(request);

            if (!_readRepository.Contains(new ContainsSpecification(notifikationEntity)))
            {
                _notifikationWrite.Add <NotifikationEntity>(notifikationEntity);
                await _notifikationWrite.SaveChangesAsync();
            }
            else
            {
                throw new NoExistsNotifikatInfrastructureException($"Message: {notifikationEntity.Message} User : {notifikationEntity.User}");
            }
            var notifikatItemDTO = _mapper.Map <NotifikatItemDTO>(notifikationEntity);

            return(notifikatItemDTO);
        }
Пример #2
0
        public async Task <UserDTO> Handle(CreateUserCommand request, CancellationToken cancellationToken)
        {
            var userEntity = _mapper.Map <UserEntity>(request);

            if (!_readRepository.Contains(new ContainsUserSpecification(userEntity)))
            {
                _notifikationWrite.Add <UserEntity>(userEntity);
                await _notifikationWrite.SaveChangesAsync();
            }
            else
            {
                throw new NoExistsUserInfrastructureException($"Email: {userEntity.Email} Name : {userEntity.Name}");
            }
            var userDTO = _mapper.Map <UserDTO>(userEntity);

            return(userDTO);
        }