public async Task <DocumentDTO> Handle(CreateDocumentCommand request, CancellationToken cancellationToken) { var documentDTO = new DocumentDTO(); documentDTO.FileName = documentDTO.FileName; documentDTO.UserId = request.UserId; documentDTO.Content = _ocrService.GetText(request.Bytes); var documentEntity = _mapper.Map <DocumentEntity>(documentDTO); _writeIRepository.Add(documentEntity); await _writeIRepository.SaveChangesAsync(); return(documentDTO); }
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); }
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); }