Bmc: Validation message for Login and Registration

This commit is contained in:
Palash Biswas 2023-01-13 16:09:49 +05:30
parent a8a988f7cf
commit 6e0884b935
6 changed files with 38 additions and 10 deletions

View File

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

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 try
{ {

View File

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

View File

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

View File

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

View File

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