public async Task <MatchResult> SendPairDecision(string pairedProfileId, PairingDecision decision) { var url = string.Format(Pairings_PostDecision_Url, Credentials.UserId); var data = new { pairProfileId = pairedProfileId, decision = decision }; var matchResult = await Post <object, MatchResult>(url, data); return(matchResult); }
public async Task <MatchResult> SetPairingDescision(string profileId, string pairedProfileId, PairingDecision decision) { var existingPairing = await _pairingsRepository.GetPairing(profileId, pairedProfileId); if (existingPairing != null) { existingPairing.UpdatedAt = DateTime.UtcNow; existingPairing.IsLiked = decision == PairingDecision.Liked; await _pairingsRepository.UpsertPairingData(existingPairing); } else { var newPairing = new PairingEntity { Id = Guid.NewGuid().ToString(), ProfileId = profileId, PairedProfileId = pairedProfileId, IsLiked = decision == PairingDecision.Liked, UpdatedAt = DateTime.UtcNow }; await _pairingsRepository.UpsertPairingData(newPairing); } var isMatch = await _pairingsRepository.CheckIfMatch(profileId, pairedProfileId); if (isMatch) { var existingMatch = (await _matchesRepository.FindMatch(profileId, pairedProfileId)); if (existingMatch == null) { var matchGuid = Guid.NewGuid().ToString(); var match = new MatchEntity { Id = matchGuid, MatchedAt = DateTime.UtcNow, ProfileMatches = new List <ProfileMatchEntity> { new ProfileMatchEntity { ProfileId = profileId, MatchId = matchGuid }, new ProfileMatchEntity { ProfileId = pairedProfileId, MatchId = matchGuid } }, MatchContactPreferences = new List <MatchContactPreferenceEntity> { new MatchContactPreferenceEntity { Id = Guid.NewGuid().ToString(), MatchId = matchGuid, ProfileId = profileId }, new MatchContactPreferenceEntity { Id = Guid.NewGuid().ToString(), MatchId = matchGuid, ProfileId = pairedProfileId } } }; await _matchesRepository.UpsertMatch(match); } } var matchResult = new MatchResult { ProfileId = profileId, PairedProfileId = pairedProfileId, IsMatch = isMatch }; return(matchResult); }
public async Task <MatchResult> SendPairingDecision(string profileId, PairingDecision decision) { var isMatch = await _pairingsClient.SendPairDecision(profileId, decision); return(isMatch); }