Exemplo n.º 1
0
        public async Task <OperationResultVo> Handle(DeleteUserFromPlatformRequest request, CancellationToken cancellationToken)
        {
            bool canDelete = true;

            var comments = await userContentAppService.GetCommentsByUserId(request.CurrentUserId, request.UserId);

            if (comments.Success)
            {
                var castResult = comments as OperationResultListVo <CommentViewModel>;

                canDelete = !castResult.Value.Any();
            }

            if (canDelete)
            {
                var profile = await profileAppService.GetByUserId(request.UserId, ProfileType.Personal, false);

                if (profile == null)
                {
                    return(new OperationResultVo(false, "Can't delete user"));
                }

                var result = profileAppService.Remove(request.CurrentUserId, profile.Id);

                return(result);
            }
            else
            {
                return(new OperationResultVo(false, "Can't delete user"));
            }
        }