private HelpRequestResponseModel MapHelpRequestResponse(HelpRequestResponse helpRequest, string userId) { var clientConfiguration = _clientConfigurationService.GetByUserId(userId); var result = new HelpRequestResponseModel { ClientId = UserId, ContactPhoneNumber = clientConfiguration.SupportNumber, HelpIncomingDateTime = helpRequest.HelpIncomingDateTimeUtc, HelpRequestState = helpRequest.HelpRequestState, ShortInstructions = helpRequest.ShortInstruction }; return(result); }
public async Task <bool> SendHelpRequestNotification(string clientId, HelpRequestResponseModel model) { var tokens = _context.FirebaseTokens.Where(x => x.IsActive && x.ClientId == clientId); if (!tokens.Any()) { return(await Task.FromResult(true)); } foreach (var item in tokens) { var requestResult = await _apiClient.SendNotification(new HelpRequestNotificationModel <HelpRequestResponseModel> { Data = model, Priority = "high", To = item.Token }); } return(true); }
public async Task <bool> SendHelpRequestNotification(string clientId, HelpRequestResponse newRequest) { HelpRequestResponseModel model; if (newRequest == null) { model = new HelpRequestResponseModel(); } else { model = new HelpRequestResponseModel { ClientId = clientId, ContactPhoneNumber = "", HelpIncomingDateTime = newRequest.HelpIncomingDateTimeUtc, HelpRequestId = newRequest.HelpRequestId, HelpRequestState = newRequest.HelpRequestState, Id = newRequest.Id, IsActive = newRequest.IsActive, ShortInstructions = newRequest.ShortInstruction }; } return(await SendHelpRequestNotification(clientId, model)); }