|
|
@ -13,6 +13,7 @@ using FireSharp.Interfaces; |
|
|
|
using FireSharp.Response; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Newtonsoft.Json; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
@ -50,11 +51,13 @@ namespace BCS.BMC.Web.Controllers |
|
|
|
[HttpPost] |
|
|
|
public async Task<IActionResult> GetNotifications([FromBody]NotificationModel notification) |
|
|
|
{ |
|
|
|
var model = ObjectMapper.Map<FirebaseNotification>(notification); |
|
|
|
|
|
|
|
client = new FireSharp.FirebaseClient(config); |
|
|
|
var data = notification; |
|
|
|
PushResponse response = client.Push("notification/", data); |
|
|
|
data.Id = response.Result.name; |
|
|
|
SetResponse setResponse = client.Set("notification/" + data.Id, data); |
|
|
|
PushResponse response = client.Push("notification/", model); |
|
|
|
model.Id = response.Result.name; |
|
|
|
SetResponse setResponse = client.Set("notification/" + model.Id, model); |
|
|
|
if (setResponse.StatusCode == System.Net.HttpStatusCode.OK) |
|
|
|
{ |
|
|
|
ModelState.AddModelError(string.Empty, "Added Succesfully"); |
|
|
@ -63,9 +66,15 @@ namespace BCS.BMC.Web.Controllers |
|
|
|
{ |
|
|
|
ModelState.AddModelError(string.Empty, "Something went wrong!!"); |
|
|
|
} |
|
|
|
try |
|
|
|
{ |
|
|
|
var entity = notification.MapTo<FirebaseCloudMessageDetails>(); |
|
|
|
await _firebaseCloudMessageDetails.InsertAndGetIdAsync(entity); |
|
|
|
}catch(Exception ex) |
|
|
|
{ |
|
|
|
|
|
|
|
var entity = notification.MapTo<FirebaseCloudMessageDetails>(); |
|
|
|
await _firebaseCloudMessageDetails.InsertAndGetIdAsync(entity); |
|
|
|
} |
|
|
|
|
|
|
|
// var result = _notificationService.GetNotification(notification);
|
|
|
|
return Ok(); |
|
|
|
} |
|
|
|