Browse Source

BMC : Remove id property from NotificationModel

feature/ModificationForSentNotificationAPI
Palash Biswas 2 years ago
parent
commit
7617b41df0
3 changed files with 24 additions and 22 deletions
  1. +3
    -3
      BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/Dto/FireStoreNotificationModel.cs
  2. +3
    -2
      BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/Dto/NotificationModel.cs
  3. +18
    -17
      BCS.BMC/src/BCS.BMC.Web.Mvc/Controllers/NotificationController.cs

+ 3
- 3
BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/Dto/FireStoreNotificationModel.cs View File

@ -12,8 +12,8 @@ namespace BCS.BMC.FirebaseCloudMessaging.Dto
{ {
[FirestoreProperty] [FirestoreProperty]
public string FcmToken { get; set; } public string FcmToken { get; set; }
[FirestoreProperty]
public List<string> Id { get; set; }
//[FirestoreProperty]
//public List<string> Id { get; set; }
[FirestoreProperty] [FirestoreProperty]
public string Message { get; set; } public string Message { get; set; }
[FirestoreProperty] [FirestoreProperty]
@ -26,6 +26,6 @@ namespace BCS.BMC.FirebaseCloudMessaging.Dto
[FirestoreProperty] [FirestoreProperty]
public bool Status { get; set; } public bool Status { get; set; }
[FirestoreProperty] [FirestoreProperty]
public int UserId { get; set; }
public List<string> UserId { get; set; }
} }
} }

+ 3
- 2
BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/Dto/NotificationModel.cs View File

@ -19,7 +19,7 @@ namespace BCS.BMC.FirebaseCloudMessaging.Dto
//public List<string> Title { get; set; } //public List<string> Title { get; set; }
//[JsonProperty("body")] //[JsonProperty("body")]
public string FcmToken { get; set; } public string FcmToken { get; set; }
public List<string> Id { get; set; }
//public List<string> Id { get; set; }
public string Message { get; set; } public string Message { get; set; }
public DateTime? MessageSentDateTime { get; set; } public DateTime? MessageSentDateTime { get; set; }
@ -27,7 +27,8 @@ namespace BCS.BMC.FirebaseCloudMessaging.Dto
public string SenderName { get; set; } public string SenderName { get; set; }
public bool Status { get; set; } public bool Status { get; set; }
public int UserId { get; set; }
public List<string> UserId { get; set; }
} }
//[AutoMapFrom(typeof(NotificationModel))] //[AutoMapFrom(typeof(NotificationModel))]


+ 18
- 17
BCS.BMC/src/BCS.BMC.Web.Mvc/Controllers/NotificationController.cs View File

@ -69,7 +69,7 @@ namespace BCS.BMC.Web.Controllers
FireStoreNotificationModel data = new FireStoreNotificationModel(); FireStoreNotificationModel data = new FireStoreNotificationModel();
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;
@ -77,16 +77,16 @@ namespace BCS.BMC.Web.Controllers
data.SenderName = notification.SenderName; data.SenderName = notification.SenderName;
data.Status= notification.Status; data.Status= notification.Status;
data.UserId = notification.UserId; data.UserId = notification.UserId;
await db.Collection("BMC_Notification").Document().SetAsync(data);
foreach (var item in notification.Id)
foreach (var item in notification.UserId)
{ {
int userId = Convert.ToInt32(item); int userId = Convert.ToInt32(item);
var getTokenDetails = _firebaseToken.GetAllList().Where(x => x.UserId == userId).FirstOrDefault(); var getTokenDetails = _firebaseToken.GetAllList().Where(x => x.UserId == userId).FirstOrDefault();
List<string> tokenList = new List<string>(); List<string> tokenList = new List<string>();
tokenList.Add(getTokenDetails.FcmToken.ToString()); tokenList.Add(getTokenDetails.FcmToken.ToString());
await db.Collection("BMC_Notification").Document().SetAsync(data);
if (getTokenDetails != null)
if (getTokenDetails != null)
{ {
var title = notification.SenderName.ToJsonString(); var title = notification.SenderName.ToJsonString();
var body = notification.Message.ToJsonString(); var body = notification.Message.ToJsonString();
@ -104,20 +104,21 @@ 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;
var entity = new FirebaseCloudMessageDetails();
entity.UserId = notification.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);
}
}
if(entity != null)
{
await _firebaseCloudMessageDetails.InsertAndGetIdAsync(entity);
}
} }
catch(Exception ex) catch(Exception ex)
{ {


Loading…
Cancel
Save