BMC: Change Conditions for UpdateBmcMessageStatus method
This commit is contained in:
parent
e7999cda7d
commit
9798125d18
@ -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; }
|
||||||
|
@ -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; }
|
||||||
}
|
}
|
||||||
|
@ -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>();
|
var requestJson = JsonConvert.SerializeObject(bmcMessageStatusInput);
|
||||||
foreach (var uId in bmcMessageStatusInput.UserId)
|
var requestContent = new StringContent(requestJson.ToString());
|
||||||
{
|
requestContent.Headers.ContentType = new MediaTypeWithQualityHeaderValue("application/json");
|
||||||
usrId.Add(uId.ToString());
|
HttpResponseMessage response = await client.PostAsync(baseUrl, requestContent);
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user