BMC: Add More Values fro login API
This commit is contained in:
parent
b8fdcf2561
commit
5509295fd7
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BCS.BMC.FirebaseCloudMessaging.Dto
|
||||||
|
{
|
||||||
|
public class BmcMessageStatusInput
|
||||||
|
{
|
||||||
|
public List<string> UserId { get; set; }
|
||||||
|
public long? ScheduleGenerationId { get; set; }
|
||||||
|
public string Status { get; set; }
|
||||||
|
public string CompanyUrl { get; set; }
|
||||||
|
public bool IsSuccess { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -12,5 +12,7 @@ namespace BCS.BMC.FirebaseCloudMessaging.Dto
|
|||||||
{
|
{
|
||||||
public Notification notification { get; set; }
|
public Notification notification { get; set; }
|
||||||
public List<string> FcmToken { get; set; }
|
public List<string> FcmToken { get; set; }
|
||||||
|
|
||||||
|
public BmcMessageStatusInput getResponseData { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,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 string CompanyUrl { get; set; }
|
public string CompanyUrl { get; set; }
|
||||||
public string ScheduleGenerationId { get; set; }
|
public long? ScheduleGenerationId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
//[AutoMapFrom(typeof(NotificationModel))]
|
//[AutoMapFrom(typeof(NotificationModel))]
|
||||||
|
@ -16,9 +16,13 @@ namespace BCS.BMC.Models.TokenAuth
|
|||||||
|
|
||||||
public int statusCode { get; set; }
|
public int statusCode { get; set; }
|
||||||
public string userName { get; set; }
|
public string userName { get; set; }
|
||||||
|
public string firstName { get; set; }
|
||||||
|
public string lastName { get; set; }
|
||||||
|
public string emailAddress { get; set; }
|
||||||
public string userId { get; set; }
|
public string userId { get; set; }
|
||||||
public string employeeId { get; set; }
|
public string employeeId { get; set; }
|
||||||
public string phoneNo { get; set; }
|
public string phoneNo { get; set; }
|
||||||
public string profilePictureId { get; set; }
|
public string profilePictureId { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,8 @@ using Newtonsoft.Json;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using System.Net.Http;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BCS.BMC.Web.Controllers
|
namespace BCS.BMC.Web.Controllers
|
||||||
@ -52,11 +54,29 @@ 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);
|
||||||
//To Do
|
|
||||||
//if ()
|
|
||||||
//{
|
if (result.SuccessCount>0)
|
||||||
// return Ok(result);
|
{
|
||||||
//}
|
if(notification.getResponseData != null)
|
||||||
|
{
|
||||||
|
notification.getResponseData.IsSuccess = true;
|
||||||
|
notification.getResponseData.Status = "Delivered";
|
||||||
|
}
|
||||||
|
await UpdateBmcMessageStatus(notification.getResponseData);
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
if (result.FailureCount > 0)
|
||||||
|
{
|
||||||
|
if (notification.getResponseData != null)
|
||||||
|
{
|
||||||
|
notification.getResponseData.IsSuccess = false;
|
||||||
|
notification.getResponseData.Status = result.Responses[0].Exception.Message;
|
||||||
|
}
|
||||||
|
await UpdateBmcMessageStatus(notification.getResponseData);
|
||||||
|
return BadRequest(result.Responses);
|
||||||
|
}
|
||||||
|
|
||||||
return Ok(result.Responses);
|
return Ok(result.Responses);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,9 +101,16 @@ namespace BCS.BMC.Web.Controllers
|
|||||||
data.Status = notification.Status;
|
data.Status = notification.Status;
|
||||||
data.UserId = notification.UserId;
|
data.UserId = notification.UserId;
|
||||||
data.CompanyId = companyDetails.Id;
|
data.CompanyId = companyDetails.Id;
|
||||||
data.ScheduleGenerationId = notification.ScheduleGenerationId;
|
data.ScheduleGenerationId = notification.ScheduleGenerationId.ToString();
|
||||||
await db.Collection("BMC_Notification").Document().SetAsync(data);
|
await db.Collection("BMC_Notification").Document().SetAsync(data);
|
||||||
|
|
||||||
|
var responseData = new BmcMessageStatusInput();
|
||||||
|
{
|
||||||
|
responseData.UserId = notification.UserId;
|
||||||
|
responseData.ScheduleGenerationId = notification.ScheduleGenerationId;
|
||||||
|
responseData.CompanyUrl = notification.CompanyUrl;
|
||||||
|
}
|
||||||
|
|
||||||
int userId = 0;
|
int userId = 0;
|
||||||
List<string> tokenList = new List<string>();
|
List<string> tokenList = new List<string>();
|
||||||
foreach (var item in notification.UserId)
|
foreach (var item in notification.UserId)
|
||||||
@ -119,6 +146,7 @@ namespace BCS.BMC.Web.Controllers
|
|||||||
//ImageUrl = null
|
//ImageUrl = null
|
||||||
};
|
};
|
||||||
sendNotificationInfo.notification = notifications;
|
sendNotificationInfo.notification = notifications;
|
||||||
|
sendNotificationInfo.getResponseData = responseData;
|
||||||
await SendNotification(sendNotificationInfo);
|
await SendNotification(sendNotificationInfo);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -127,5 +155,39 @@ namespace BCS.BMC.Web.Controllers
|
|||||||
}
|
}
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<IActionResult> UpdateBmcMessageStatus([FromBody] BmcMessageStatusInput bmcMessageStatusInput)
|
||||||
|
{
|
||||||
|
var companyDetails = _companyMasterService.GetAllList().Where(x => x.Url.Trim() == bmcMessageStatusInput.CompanyUrl.Trim()).FirstOrDefault();
|
||||||
|
var baseUrl = companyDetails.Url + "api/services/bwac/updateBmcMessageStatus/UpdateMessageStatus";
|
||||||
|
if (baseUrl == null)
|
||||||
|
{
|
||||||
|
return BadRequest("Invalid Company Url");
|
||||||
|
}
|
||||||
|
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
|
||||||
|
{
|
||||||
|
UserId =int.Parse(userid),
|
||||||
|
ScheduleGenerationId = bmcMessageStatusInput.ScheduleGenerationId,
|
||||||
|
Status = bmcMessageStatusInput.Status,
|
||||||
|
CompanyUrl = bmcMessageStatusInput.CompanyUrl,
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user