public async Task<List<Notification>> GetNotifications()
{
HttpResponseMessage response = null;
HttpRequestMessage request = null;
using (var httpClient = new HttpClient())
{
request = new HttpRequestMessage(HttpMethod.Get, new Uri(Const.UrlNotifyWithTimeStamp));
response = await httpClient.SendRequestAsync(request);
}
var respList = (JObject)JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync());
List<Notification> notList = new List<Notification>();
if (respList.HasValues)
{
var c = respList.First.First;
for (int i = 0; i < c.Count(); i++)
{
var ele = (JProperty)c.ElementAt(i);
Notification n = JsonConvert.DeserializeObject<Notification>(ele.Value.ToString());
n.AddedDate = new DateTime(1970, 1, 1).AddMilliseconds((long)(((JValue)ele.Value["Data"]).Value));
n.PublicationId = ele.Name.Split(':')[0];
n.Id = ele.Name.Split(':')[1];
n.TypeValue = Enum.ParseToNotificationType(((JValue)ele.Value["Type"]).Value.ToString());
notList.Add(n);
}
}
notList = notList.OrderBy(n => n.Status).ThenByDescending(n => n.AddedDate).ToList();
return notList;
}