public bool SendFriendRequest(int senderId, int receiverId) { if (!senderId.Equals(receiverId)) { var sender = GetProfileById(senderId, x => x.Friends); var receiver = GetProfileById(receiverId, x => x.Friends); if (sender == null || receiver == null) { return(false); } if (sender.Friends.Select(x => x.FriendId).Contains(receiverId)) { return(false); } var duplicates = _inviteRepository.GetInvites( x => (x.senderId == senderId && x.receiverId == receiverId) || (x.senderId == receiverId && x.receiverId == senderId)).Count(); if (duplicates == 0) { return(!_inviteRepository.CreateInvite(senderId, receiverId).Equals("")); } } return(false); }
public async Task <IActionResult> GetInvitesToJoinWallet(string userId) { if (User.FindFirst(ClaimTypes.NameIdentifier).Value == userId) { var user = await _userManager.Users.FirstOrDefaultAsync(u => u.Id == userId); if (user != null) { var result = await _repository.GetInvites(userId); return(Ok(result)); } return(BadRequest("No invites have been found")); } return(Unauthorized()); }