public async Task <IActionResult> Accept([FromRoute] Guid fromUserId)
        {
            var result = await _socialService.AcceptFriendshipRequestAsync(await GetAuthenticatedUserAccount(), fromUserId);

            if (result.Failed)
            {
                return(BadRequest());
            }
            await _hubContext.Clients
            .User(fromUserId.ToString())
            .SendAsync(
                FriendshipHub.FriendshipRequestAcceptedMessage,
                FriendshipRequestViewModel.FromEntity(result.Data)
                );

            return(Ok());
        }
Пример #2
0
        public async Task <IActionResult> Delete([FromRoute] Guid friendId)
        {
            var result = await _socialService.RemoveFriend(await GetAuthenticatedUserAccount(), friendId);

            if (result.Failed)
            {
                return(BadRequest(new ValidationErrorResponse(result.Error)));
            }
            await _hubContext.Clients
            .User(friendId.ToString())
            .SendAsync(
                FriendshipHub.FriendshipRemovedMessage,
                FriendshipRequestViewModel.FromEntity(result.Data)
                );

            return(NoContent());
        }
        public async Task <IActionResult> Send([FromBody] SendFriendshipRequestDto friendshipRequestDto)
        {
            friendshipRequestDto.From = await GetAuthenticatedUserAccount();

            var result = await _socialService.SendFriendshipRequest(friendshipRequestDto);

            if (result.Failed)
            {
                return(BadRequest(new ValidationErrorResponse(result.Error)));
            }
            await _hubContext.Clients
            .User(result.Data.ToId.ToString())
            .SendAsync(
                FriendshipHub.FriendshipRequestReceivedMessage,
                FriendshipRequestViewModel.FromEntity(result.Data)
                );

            return(Ok());
        }
Пример #4
0
        public async Task <ActionResult> SendFriendshipRequest(
            [FromBody] FriendshipRequestViewModel friendshipRequestViewModel)
        {
            var friendship = await _friendService.Get(friendshipRequestViewModel.RecipientUserId,
                                                      friendshipRequestViewModel.SenderUserId);

            if (friendship != null)
            {
                return(BadRequest("User is already your friend"));
            }

            var friendshipRequestDto =
                Mapper.Map <FriendshipRequestViewModel, FriendshipRequestDTO>(friendshipRequestViewModel);

            await _friendshipRequestService
            .Send(friendshipRequestDto);


            return(Ok());
        }
Пример #5
0
 public IHttpActionResult RequestSubscriberFriendship([FromBody] FriendshipRequestViewModel friendshipRequest)
 {
     return(Ok());
 }