BMC : Remove id property from NotificationModel
This commit is contained in:
parent
84cb9d4251
commit
7617b41df0
@ -12,8 +12,8 @@ namespace BCS.BMC.FirebaseCloudMessaging.Dto
|
|||||||
{
|
{
|
||||||
[FirestoreProperty]
|
[FirestoreProperty]
|
||||||
public string FcmToken { get; set; }
|
public string FcmToken { get; set; }
|
||||||
[FirestoreProperty]
|
//[FirestoreProperty]
|
||||||
public List<string> Id { get; set; }
|
//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; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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))]
|
||||||
|
@ -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();
|
if (entity != null)
|
||||||
entity.UserId = notification.UserId;
|
{
|
||||||
entity.SenderImageurl = notification.SenderImageurl;
|
await _firebaseCloudMessageDetails.InsertAndGetIdAsync(entity);
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user