Ejemplo n.º 1
0
        public bool Handle(NewCommentRequest request, IOutputPort <NewCommentResponse> outputPort)
        {
            if (_userRepository.FindById(request.UserId) == null)
            {
                outputPort.Handle(new NewCommentResponse(new[] { new Error(404, "user not found") }));
                return(false);
            }
            if (_videoRepository.FindById(request.VideoId) == null)
            {
                outputPort.Handle(new NewCommentResponse(new[] { new Error(404, "video not found") }));
                return(false);
            }
            var commentInfo = new CommentDto()
            {
                PostingDate = request.PostingDate,
                Text        = request.Text,
                UserId      = request.UserId,
                VideoId     = request.VideoId,
            };
            int commentId = _commentRepository.Create(commentInfo);

            outputPort.Handle(new NewCommentResponse(commentId));

            return(true);
        }
Ejemplo n.º 2
0
        public void Handle(UploadVideoStreamCommand message)
        {
            var video = _repository.FindById(new VideoId(message.VideoId));
            var url   = _service.Send(message.File, message.FileName);
            var file  = new VideoFile(video.Id, message.Name, url);

            video.AttachFile(file);

            _repository.Update(video);
        }
 public bool Handle(DislikeProcessingRequest request, IOutputPort <DislikeProcessingResponse> outputPort)
 {
     if (_userRepository.FindById(request.UserId) == null)
     {
         outputPort.Handle(new DislikeProcessingResponse(new[] { new Error(404, "user not found") }));
         return(false);
     }
     if (_videoRepository.FindById(request.VideoId) == null)
     {
         outputPort.Handle(new DislikeProcessingResponse(new[] { new Error(404, "video not found") }));
         return(false);
     }
     _videoRepository.HandleDislike(request.VideoId, request.UserId);
     outputPort.Handle(new DislikeProcessingResponse());
     return(true);
 }
Ejemplo n.º 4
0
 public Video FindVideoById(int id)
 {
     return(_videoRepository.FindById(id));
 }