Esempio n. 1
0
        public async Task <bool> Handle(DeleteClipboardEntryRequest request, CancellationToken cancellationToken)
        {
            var entity = await _entityContext.GetById(request.Id);

            if (entity == null)
            {
                return(false);
            }

            var isDeleted = await _entityContext.Delete(request.Id);

            if (!isDeleted)
            {
                throw new RpcException(new Status(StatusCode.Unknown,
                                                  $"Failed deleting clipboard entry with Id {request.Id}"));
            }

            var entry = _mapper.Map <ClipboardEntryDto, ClipboardEntry>(entity);

            _broadcasterService.AddClipboardEntry(new ClipboardEntryMessage
            {
                ClipboardEntry = entry, ClipboardUpdateType = ClipboardUpdateType.Deleted
            });

            return(true);
        }
Esempio n. 2
0
        public async Task <bool> Handle(CreateClipboardEntryCommandRequest request, CancellationToken cancellationToken)
        {
            var entity =
                await _clipboardEntityContext.Create(new ClipboardEntryDto(request.Request.Content,
                                                                           request.Request.CreatedBy));

            if (entity == null)
            {
                throw new RpcException(new Status(StatusCode.Unknown, "Failed creating clipboard entry"));
            }

            var entry = _mapper.Map <ClipboardEntryDto, ClipboardEntry>(entity);

            _broadcasterService.AddClipboardEntry(new ClipboardEntryMessage
            {
                ClipboardEntry = entry, ClipboardUpdateType = ClipboardUpdateType.Created
            });

            return(true);
        }