From 84cb9d42510868a71b24e40c22ab25321b3511c1 Mon Sep 17 00:00:00 2001 From: Palash Biswas Date: Fri, 9 Dec 2022 12:50:56 +0530 Subject: [PATCH] BMC: Parameter binding issue in SendNotification Method --- .../Controllers/NotificationController.cs | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/BCS.BMC/src/BCS.BMC.Web.Mvc/Controllers/NotificationController.cs b/BCS.BMC/src/BCS.BMC.Web.Mvc/Controllers/NotificationController.cs index 0de920a..037a91e 100644 --- a/BCS.BMC/src/BCS.BMC.Web.Mvc/Controllers/NotificationController.cs +++ b/BCS.BMC/src/BCS.BMC.Web.Mvc/Controllers/NotificationController.cs @@ -78,19 +78,33 @@ namespace BCS.BMC.Web.Controllers data.Status= notification.Status; data.UserId = notification.UserId; await db.Collection("BMC_Notification").Document().SetAsync(data); - var getTokenDetails = _firebaseToken.GetAllList().Where(x => x.UserId == notification.UserId).FirstOrDefault(); - List tokenList = new List(); - tokenList.Add(getTokenDetails.FcmToken); + foreach (var item in notification.Id) + { + int userId = Convert.ToInt32(item); + var getTokenDetails = _firebaseToken.GetAllList().Where(x => x.UserId == userId).FirstOrDefault(); + List tokenList = new List(); + tokenList.Add(getTokenDetails.FcmToken.ToString()); + if (getTokenDetails != null) { - var sendNotificationInfo = new FireBaseResponseModel(); - sendNotificationInfo.FcmToken = tokenList; - sendNotificationInfo.notification.Title = "Bwac Patrol Monitoring Alert"; - sendNotificationInfo.notification.Body = notification.Message; - await SendNotification(sendNotificationInfo); + var title = notification.SenderName.ToJsonString(); + var body = notification.Message.ToJsonString(); + var sendNotificationInfo = new FireBaseResponseModel(); + { + sendNotificationInfo.FcmToken = tokenList; + } + + Notification notifications = new Notification + { + Title = title, + Body = body, + //ImageUrl = null + }; + sendNotificationInfo.notification = notifications; + await SendNotification(sendNotificationInfo); } - + } var entity = new FirebaseCloudMessageDetails(); entity.UserId = notification.UserId;