public async Task <IActionResult> AcceptRequestAndGiveAccess(string userId, string emailToAccept)
        {
            //emailToAccept += "@mail.com";
            if (User.FindFirst(ClaimTypes.NameIdentifier).Value == userId)
            {
                var user = await _userManager.Users.FirstOrDefaultAsync(u => u.Id == userId);

                var userToAccept = await _userManager.Users.FirstOrDefaultAsync(u => u.Email == emailToAccept);

                if (user != null)
                {
                    var result = await _repository.AcceptRequest(emailToAccept, user.WalletID);

                    if (result.isSuccessful)
                    {
                        await _noteRepository.DeleteRequestAndInviteNotifications(userToAccept);

                        await _noteRepository.CreateNotification(user.Id, userToAccept.Id, "NewMember", $"Member {userToAccept.UserName} has joined the wallet!", true);

                        return(Ok(result.Message));
                    }
                    return(BadRequest(result.Message));
                }
                return(BadRequest("User is not correct"));
            }
            return(Unauthorized());
        }
Esempio n. 2
0
 public void AcceptRequest(Request request)
 {
     _requestRepository.AcceptRequest(request);
 }