public async System.Threading.Tasks.Task <bool> AddImageCommentAsync(string commentText, string imageName, string userEmail, string userCommentEmail)
        {
            var isValidUser = await ValidateUserByEmailAsync(userEmail);

            var isValidUserComment = await ValidateUserByEmailAsync(userCommentEmail);

            if (isValidUser && isValidUserComment)
            {
                var imagesResponse = await _clientRepository.GetUserImagesAsync(new AddUserRequest { UserEmail = userEmail });

                var isValidImage = ValidateImageByName(imageName, imagesResponse.Images);
                if (isValidImage)
                {
                    var comment = new CommentProto
                    {
                        Text      = commentText,
                        UserEmail = userCommentEmail,
                    };
                    var addImageCommentRequest = new AddImageCommentRequest
                    {
                        UserEmail = userEmail,
                        ImageName = imageName,
                        Comment   = comment
                    };
                    await _clientRepository.AddImageCommentAsync(addImageCommentRequest);
                }
                return(isValidImage);
            }
            return(isValidUser && isValidUserComment);
        }
Esempio n. 2
0
        public override Task <EmptyMessagee> AddImageComment(AddImageCommentRequest request, ServerCallContext context)
        {
            var comment = new Comment
            {
                Text      = request.Comment.Text,
                UserEmail = request.Comment.UserEmail,
            };

            _userRepository.AddImageComment(request.UserEmail, request.ImageName, comment);
            _logSenderService.SendMessages("added a new comment to the user " + request.UserEmail + " image " + request.ImageName);
            return(Task.FromResult(new EmptyMessagee {
            }));
        }