Beispiel #1
0
        public async Task <FriendRequestModel> SendFriendRequest(string SourceId, string TargetId)
        {
            FriendRequestModel result = null;

            if (!await AreUsersFriends(SourceId, TargetId) &&
                !await _blockService.IsUserBlocked(SourceId, TargetId) &&
                !await _friendRepository.HasPendingRequest(SourceId, TargetId))
            {
                result = await _friendRepository.SendFriendRequest(SourceId, TargetId);
            }
            else if (await _friendRepository.HasPendingRequest(TargetId, SourceId))
            {
                var request = await _friendRepository.FindRequest(TargetId, SourceId);
                await AnswerFriendRequest(request.Id, true);

                result = await _friendRepository.GetRequest(request.Id);
            }

            return(result);
        }