Browse Source

BMC: Change Conditions for UpdateBmcMessageStatus method

feature/ModificationForSentNotificationAPI
Palash Biswas 2 years ago
parent
commit
9798125d18
3 changed files with 14 additions and 29 deletions
  1. +1
    -0
      BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/Dto/BmcMessageStatusInput.cs
  2. +1
    -0
      BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/Dto/NotificationModel.cs
  3. +12
    -29
      BCS.BMC/src/BCS.BMC.Web.Mvc/Controllers/NotificationController.cs

+ 1
- 0
BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/Dto/BmcMessageStatusInput.cs View File

@ -10,6 +10,7 @@ namespace BCS.BMC.FirebaseCloudMessaging.Dto
{ {
public List<string> UserId { get; set; } public List<string> UserId { get; set; }
public long? ScheduleGenerationId { get; set; } public long? ScheduleGenerationId { get; set; }
public List<long> BmcIDs { get; set; }
public string Status { get; set; } public string Status { get; set; }
public string CompanyUrl { get; set; } public string CompanyUrl { get; set; }
public bool IsSuccess { get; set; } public bool IsSuccess { get; set; }


+ 1
- 0
BCS.BMC/src/BCS.BMC.Application/FirebaseCloudMessaging/Dto/NotificationModel.cs View File

@ -23,6 +23,7 @@ namespace BCS.BMC.FirebaseCloudMessaging.Dto
public bool Status { get; set; } public bool Status { get; set; }
public List<string> UserId { get; set; } public List<string> UserId { get; set; }
public List<long> BmcIDs { get; set; }
public string CompanyUrl { get; set; } public string CompanyUrl { get; set; }
public long? ScheduleGenerationId { get; set; } public long? ScheduleGenerationId { get; set; }
} }


+ 12
- 29
BCS.BMC/src/BCS.BMC.Web.Mvc/Controllers/NotificationController.cs View File

@ -54,11 +54,11 @@ namespace BCS.BMC.Web.Controllers
public async Task<IActionResult> SendNotification([FromBody] FireBaseResponseModel notification) public async Task<IActionResult> SendNotification([FromBody] FireBaseResponseModel notification)
{ {
var result = await _notificationService.SendNotification(notification); var result = await _notificationService.SendNotification(notification);
if (result.SuccessCount>0)
if (result.SuccessCount > 0)
{ {
if(notification.getResponseData != null)
if (notification.getResponseData != null)
{ {
notification.getResponseData.IsSuccess = true; notification.getResponseData.IsSuccess = true;
notification.getResponseData.Status = "Delivered"; notification.getResponseData.Status = "Delivered";
@ -76,7 +76,7 @@ namespace BCS.BMC.Web.Controllers
await UpdateBmcMessageStatus(notification.getResponseData); await UpdateBmcMessageStatus(notification.getResponseData);
return BadRequest(result.Responses); return BadRequest(result.Responses);
} }
return Ok(result.Responses); return Ok(result.Responses);
} }
@ -108,7 +108,8 @@ namespace BCS.BMC.Web.Controllers
{ {
responseData.UserId = notification.UserId; responseData.UserId = notification.UserId;
responseData.ScheduleGenerationId = notification.ScheduleGenerationId; responseData.ScheduleGenerationId = notification.ScheduleGenerationId;
responseData.CompanyUrl = notification.CompanyUrl;
responseData.CompanyUrl = notification.CompanyUrl;
responseData.BmcIDs = notification.BmcIDs;
} }
int userId = 0; int userId = 0;
@ -160,32 +161,14 @@ namespace BCS.BMC.Web.Controllers
{ {
var companyDetails = _companyMasterService.GetAllList().Where(x => x.Url.Trim() == bmcMessageStatusInput.CompanyUrl.Trim()).FirstOrDefault(); var companyDetails = _companyMasterService.GetAllList().Where(x => x.Url.Trim() == bmcMessageStatusInput.CompanyUrl.Trim()).FirstOrDefault();
var baseUrl = companyDetails.Url + "api/services/bwac/updateBmcMessageStatus/UpdateMessageStatus"; var baseUrl = companyDetails.Url + "api/services/bwac/updateBmcMessageStatus/UpdateMessageStatus";
if (baseUrl == null)
{
return BadRequest("Invalid Company Url");
}
using (HttpClient client = new HttpClient()) using (HttpClient client = new HttpClient())
{ {
List<string> usrId = new List<string>();
foreach (var uId in bmcMessageStatusInput.UserId)
{
usrId.Add(uId.ToString());
}
foreach (var userid in usrId)
{
var data = new BmcMessageStatusInput();
{
data.UserId = bmcMessageStatusInput.UserId;
data.ScheduleGenerationId = bmcMessageStatusInput.ScheduleGenerationId;
data.Status = bmcMessageStatusInput.Status.ToString();
data.CompanyUrl = bmcMessageStatusInput.CompanyUrl;
data.IsSuccess = bmcMessageStatusInput.IsSuccess;
};
var requestJson = JsonConvert.SerializeObject(data);
var requestContent = new StringContent(requestJson.ToString());
requestContent.Headers.ContentType = new MediaTypeWithQualityHeaderValue("application/json");
HttpResponseMessage response = await client.PostAsync(baseUrl, requestContent);
}
var requestJson = JsonConvert.SerializeObject(bmcMessageStatusInput);
var requestContent = new StringContent(requestJson.ToString());
requestContent.Headers.ContentType = new MediaTypeWithQualityHeaderValue("application/json");
HttpResponseMessage response = await client.PostAsync(baseUrl, requestContent);
return Ok(); return Ok();
} }
} }


Loading…
Cancel
Save