public ActionResult Index(PostNotificationModel model) { _userRegistrationBs.SendPushNotification(model); ViewBag.CategoryList = new SelectList(_userRegistrationBs.CategoryList(), "Id", "Name"); ViewBag.UserGroupList = _userGroupBS.UserGroupList(); return(View()); }
public async Task SendNotificationAsync(PostNotificationModel postNotificationModel) { foreach (var item in postNotificationModel.RecipientsList) { await SendOneNotificationAsync(item); } }
public async Task SendNotificationTest() { var postNotificationModel = new PostNotificationModel() { Content = "Notification Test", RecipientsList = new string[] { this.userId.ToString() }, WithAttachments = false, ContentType = "string", }; await this.notificationService.SendNotificationAsync(postNotificationModel); }
public IActionResult PostMail([FromBody] PostMailModel mail) { NotificationController notificationController = new NotificationController(new NotificationService()); var userId = this.GetUserId(); PostNotificationModel postNotificationModel = new PostNotificationModel { Content = mail.Text, ContentType = "string", RecipientsList = mail.To, WithAttachments = mail.Attachments.Length > 0 ? true : false, }; var result = notificationController.PostNotification(postNotificationModel); this._mailService.SendMail(mail, userId); return(this.NoContent()); }
public IActionResult PostNotification([FromBody] PostNotificationModel notification) { this.notificationService.SendNotificationAsync(notification); return(this.NoContent()); }
public void SendPushNotification(PostNotificationModel model) { var userIds = new List <int>(); if (model.UserType == 1)//if usertype is usergroup { if (model.UserGroupList.Count == 0) { return; } userIds = tbl_userGroupMap.GetWithInclude(x => model.UserGroupList.Contains(x.UserGroupID.Value)).Select(x => x.UserID.Value).ToList(); } else // else categoryId { userIds = tbl_UserCategoryMap.GetWithInclude(x => x.CategoryID == model.CategoryID && x.IsSelected == true).Select(x => x.UserID).ToList(); } if (userIds.Count == 0) { return; } if (model.IsMobileNotification) { var deviceList = tbl_UserRegistration.GetWithInclude(x => userIds.Contains(x.Id) && x.DeviceID != null).Select(x => x.DeviceID).ToList(); if (deviceList.Count > 0) { //deviceList.ForEach(x => //{ // FCMClient client = new FCMClient("AAAAylgXv6E:APA91bHxCtlKnoU7NBp9P989-zIh8KS6oy6dG2ESyReH6DyaawXz9zfyogpiO6STy7-8ajMzlvpi1jAQ0VqOkKjSf8DtOk5vNbklD9q-F1V3rmAnR_oH-zYamaeTludLGqItoSjykVDe"); // var message = new Message() // { // To = x, // Notification = new AndroidNotification() // { // Title = model.Message, // } // }; // var result = client.SendMessageAsync(message); //}); new SendSMS().SendPushNotification(deviceList, model.Message, "3"); } } if (model.IsSms) { string mobile = string.Empty; var mobileList = tbl_UserRegistration.GetWithInclude(x => userIds.Contains(x.Id) && x.Contact != null).Select(x => x.Contact).ToList(); if (mobileList.Count == 0) { return; } if (mobileList.Count > 0) { mobileList.ForEach(x => { mobile += x + ","; }); mobile = mobile.Remove(mobile.Length - 1); new SendSMS().Send(mobile, model.Message); } } }