Exemplo n.º 1
0
        public async Task <ActionResult> Follow(FollowRequestModel model)
        {
            var result = await this.follows.Follow(model.UserId, this.currentUser.GetId());

            if (result.Failure)
            {
                return(BadRequest(result.Error));
            }

            return(Ok());
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Follow(FollowRequestModel model)
        {
            var result = await this.followService.Follow(
                model.UserId,
                this.currentUser.GetId());

            if (result.Failure)
            {
                return(this.BadRequest(result.Error));
            }

            var notificationId = await this.notificationService.CreateAsync(model.UserId, this.currentUser.GetId(), string.Format(FollowNotification, this.currentUser.GetUserName()), "Follow");

            var notification = await this.notificationService.GetNotificationById <NotificationsByUserServiceModel>(notificationId);

            await this.notificationHub.Clients.User(model.UserId).SendAsync("NewNotificationReceived", notification);

            return(this.Ok());
        }