Browse Source

Bmc: Validation message for Login and Registration

feature/IndividualSendNotificationFunctionality
Palash Biswas 2 years ago
parent
commit
6e0884b935
6 changed files with 38 additions and 10 deletions
  1. +5
    -0
      BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/Dto/FirebaseResponseModel.cs
  2. +20
    -1
      BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/FirebaseNotificationAppService.cs
  3. +2
    -1
      BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/IFirebaseNotificationAppService.cs
  4. +1
    -1
      BCS.BMC/src/BCS.BMC.Web.Core/Controllers/TokenAuthController.cs
  5. +0
    -1
      BCS.BMC/src/BCS.BMC.Web.Core/Models/TokenAuth/ResponseMessageModel.cs
  6. +10
    -6
      BCS.BMC/src/BCS.BMC.Web.Mvc/Controllers/NotificationController.cs

+ 5
- 0
BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/Dto/FirebaseResponseModel.cs View File

@ -15,4 +15,9 @@ namespace BCS.BMC.FirebaseCloudMessaging.Dto
public BmcMessageStatusInput getResponseData { get; set; }
}
public class FireBaseResponseModelForBmc
{
public Notification notification { get; set; }
public List<string> FcmToken { get; set; }
}
}

+ 20
- 1
BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/FirebaseNotificationAppService.cs View File

@ -25,7 +25,26 @@ namespace BCS.BMC.FirebaseCloudMessaging
}
public async Task<BatchResponse> SendNotification(FireBaseResponseModel notification)
public async Task<BatchResponse> SendNotification(FireBaseResponseModelForBmc notification)
{
try
{
var message = new MulticastMessage()
{
Notification = notification.notification,
Tokens = notification.FcmToken,
};
var response = await FirebaseMessaging.DefaultInstance.SendMulticastAsync(message);
return response;
}
catch (Exception ex)
{
throw ex;
}
}
public async Task<BatchResponse> SendNotificationBwac(FireBaseResponseModel notification)
{
try
{


+ 2
- 1
BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/IFirebaseNotificationAppService.cs View File

@ -7,7 +7,8 @@ namespace BCS.BMC.FirebaseCloudMessaging
{
public interface IFirebaseNotificationAppService : IApplicationService
{
Task<BatchResponse> SendNotification(FireBaseResponseModel notification);
Task<BatchResponse> SendNotification(FireBaseResponseModelForBmc notification);
Task GetNotification(NotificationModel notification);
Task<BatchResponse> SendNotificationBwac(FireBaseResponseModel notification);
}
}

+ 1
- 1
BCS.BMC/src/BCS.BMC.Web.Core/Controllers/TokenAuthController.cs View File

@ -405,7 +405,7 @@ namespace BCS.BMC.Controllers
{
var contents = await response.Content.ReadAsStringAsync();
ResponseMessageModel result = JsonConvert.DeserializeObject<ResponseMessageModel>(contents);
return BadRequest(result);
return BadRequest(result.error.message.ToString());
}
}
return BadRequest();


+ 0
- 1
BCS.BMC/src/BCS.BMC.Web.Core/Models/TokenAuth/ResponseMessageModel.cs View File

@ -14,6 +14,5 @@ namespace BCS.BMC.Models.TokenAuth
public class Error
{
public string message { get; set; }
}
}

+ 10
- 6
BCS.BMC/src/BCS.BMC.Web.Mvc/Controllers/NotificationController.cs View File

@ -24,6 +24,7 @@ using Abp.EntityFrameworkCore.Repositories;
using System.Security.Cryptography;
using Abp.Domain.Uow;
using Google.Type;
using Microsoft.AspNetCore.Http;
namespace BCS.BMC.Web.Controllers
{
@ -58,12 +59,18 @@ namespace BCS.BMC.Web.Controllers
[HttpPost]
public async Task<IActionResult> SendNotification([FromBody] List<FireBaseResponseModel> notifications)
public async Task<SendResponse> SendNotification([FromBody] FireBaseResponseModelForBmc notification)
{
var result = await _notificationService.SendNotification(notification);
return result.Responses[0];
}
public async Task<IActionResult> SendNotificationForBwac([FromBody] List<FireBaseResponseModel> notifications)
{
List<BmcMessageStatusInput> bmcMessageStatusInputs = new List<BmcMessageStatusInput>();
foreach (var notification in notifications)
{
var result = await _notificationService.SendNotification(notification);
var result = await _notificationService.SendNotificationBwac(notification);
if (result.SuccessCount > 0)
{
@ -72,8 +79,6 @@ namespace BCS.BMC.Web.Controllers
notification.getResponseData.IsSuccess = true;
notification.getResponseData.Status = "Delivered";
}
// return Ok(result);
}
if (result.FailureCount > 0)
{
@ -83,7 +88,6 @@ namespace BCS.BMC.Web.Controllers
notification.getResponseData.Status = result.Responses[0].Exception.Message;
}
//await UpdateBmcMessageStatus(notification.getResponseData);
return BadRequest(result.Responses);
}
bmcMessageStatusInputs.Add(notification.getResponseData);
}
@ -189,7 +193,7 @@ namespace BCS.BMC.Web.Controllers
}
await uow.CompleteAsync();
}
await SendNotification(sendNotificationInfoList);
await SendNotificationForBwac(sendNotificationInfoList);
}
catch (Exception ex)
{


Loading…
Cancel
Save