public async Task AcceptFriendRequestAsync(int friendRequestId) { using (var transaction = _repository.BeginTransaction()) { await ChangeFriendRequestStatus(friendRequestId, FriendshipStatus.Lasts); var friendship = await GetFriendRequestAsync(friendRequestId); if (friendship == null) { throw new FriendRequestException("The friend request you referenced does not exist in the system."); } var groupAll = await _groupsService.GetGroupByNamesAsync( friendship.UserFrom.UserName, _groupsOptions.AllFriendsGroupName); await _groupsService.AddUserToGroupAsync(friendship.UserTo.UserName, groupAll.Id); groupAll = await _groupsService.GetGroupByNamesAsync( friendship.UserTo.UserName, _groupsOptions.AllFriendsGroupName); await _groupsService.AddUserToGroupAsync(friendship.UserFrom.UserName, groupAll.Id); transaction.Commit(); } }