public async Task <bool> Handle(RemoveNewsRecord request, CancellationToken cancellationToken) { try { var result = await _repository.RemoveById(request.RemoveNewsRecordDto.Id); await _repository.SaveAsync(cancellationToken); return(result); } catch (Exception e) { _logger.LogError(nameof(RemoveNewsRecordHandler.Handle), e); return(false); } }
public async Task <bool> Handle(CreateNewsRecord request, CancellationToken cancellationToken) { try { var result = _mapper.Map <NewsRecord>(request.NewsRecordDto); var response = await _repository.CreateAsync(result); await _repository.SaveAsync(cancellationToken); return(response); } catch (Exception e) { _logger.LogError(nameof(CreateNewsRecordHandler.Handle), e); return(false); } }