BMC: Change msgSent datetime value in GetNotifications Method

This commit is contained in:
Palash Biswas 2022-12-14 17:21:29 +05:30
parent 7617b41df0
commit 3682a17d53

View File

@ -71,23 +71,35 @@ namespace BCS.BMC.Web.Controllers
data.FcmToken = notification.FcmToken; data.FcmToken = notification.FcmToken;
// data.Id = notification.Id; // data.Id = notification.Id;
data.Message = notification.Message; data.Message = notification.Message;
//data.MessageSentDateTime = notification.MessageSentDateTime; data.MessageSentDateTime = notification.MessageSentDateTime;
data.MessageSentDateTime = DateTime.UtcNow; //data.MessageSentDateTime = DateTime.UtcNow;
data.SenderImageurl = notification.SenderImageurl; data.SenderImageurl = notification.SenderImageurl;
data.SenderName = notification.SenderName; data.SenderName = notification.SenderName;
data.Status = notification.Status; data.Status = notification.Status;
data.UserId = notification.UserId; data.UserId = notification.UserId;
foreach (var item in notification.UserId)
{
int userId = Convert.ToInt32(item);
var getTokenDetails = _firebaseToken.GetAllList().Where(x => x.UserId == userId).FirstOrDefault();
List<string> tokenList = new List<string>();
tokenList.Add(getTokenDetails.FcmToken.ToString());
await db.Collection("BMC_Notification").Document().SetAsync(data); await db.Collection("BMC_Notification").Document().SetAsync(data);
if (getTokenDetails != null) int userId = 0;
List<string> tokenList = new List<string>();
foreach (var item in notification.UserId)
{ {
userId = Convert.ToInt32(item);
var getTokenDetails = _firebaseToken.GetAllList().Where(x => x.UserId == userId).FirstOrDefault();
tokenList.Add(getTokenDetails.FcmToken.ToString());
var entity = new FirebaseCloudMessageDetails();
entity.UserId = userId;
entity.SenderImageurl = notification.SenderImageurl;
entity.SenderName = notification.SenderName;
entity.MessageSentDateTime = notification.MessageSentDateTime;
entity.Status = notification.Status;
entity.Message = notification.Message;
if (entity != null)
{
await _firebaseCloudMessageDetails.InsertAndGetIdAsync(entity);
}
}
var title = notification.SenderName.ToJsonString(); var title = notification.SenderName.ToJsonString();
var body = notification.Message.ToJsonString(); var body = notification.Message.ToJsonString();
var sendNotificationInfo = new FireBaseResponseModel(); var sendNotificationInfo = new FireBaseResponseModel();
@ -103,22 +115,6 @@ namespace BCS.BMC.Web.Controllers
}; };
sendNotificationInfo.notification = notifications; sendNotificationInfo.notification = notifications;
await SendNotification(sendNotificationInfo); await SendNotification(sendNotificationInfo);
}
var entity = new FirebaseCloudMessageDetails();
entity.UserId = userId;
entity.SenderImageurl = notification.SenderImageurl;
entity.SenderName = notification.SenderName;
entity.MessageSentDateTime = notification.MessageSentDateTime;
entity.Status = notification.Status;
entity.Message = notification.Message;
if (entity != null)
{
await _firebaseCloudMessageDetails.InsertAndGetIdAsync(entity);
}
}
} }
catch (Exception ex) catch (Exception ex)
{ {