diff --git a/server/AyaNova/Controllers/NotifyController.cs b/server/AyaNova/Controllers/NotifyController.cs
index 34fbede3..c7280434 100644
--- a/server/AyaNova/Controllers/NotifyController.cs
+++ b/server/AyaNova/Controllers/NotifyController.cs
@@ -57,17 +57,15 @@ namespace AyaNova.Api.Controllers
///
///
[HttpGet("new-count")]
- public ActionResult GetNewCount()
+ public async Task GetNewCount()
{
- //STUB: https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/3783
if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
- System.Random rnd = new System.Random();
- int RandomNewCount = rnd.Next(20);
- return Ok(ApiOkResponse.Response(RandomNewCount));
+ var UserId = UserIdFromContext.Id(HttpContext.Items);
+ return Ok(ApiOkResponse.Response(await ct.Notification.CountAsync(z => z.UserId == UserId && z.Fetched == false)));
}
-
+
//------------
diff --git a/server/AyaNova/models/Notification.cs b/server/AyaNova/models/Notification.cs
index c0d05804..d77800ed 100644
--- a/server/AyaNova/models/Notification.cs
+++ b/server/AyaNova/models/Notification.cs
@@ -14,6 +14,8 @@ namespace AyaNova.Models
public long Id { get; set; }
public uint Concurrency { get; set; }
+ [Required]
+ public long UserId { get; set; }
[Required]
public DateTime Created { get; set; }
public AyaType? AyaType { get; set; }
@@ -24,12 +26,12 @@ namespace AyaNova.Models
public long SubscriptionId { get; set; }
public string Message { get; set; }
[Required]
- public bool Fetched {get;set;}
+ public bool Fetched { get; set; }
public Notification()
{
Created = DateTime.UtcNow;
- Fetched=false;
+ Fetched = false;
}
}//eoc
diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs
index 802499a9..f3c6e3a8 100644
--- a/server/AyaNova/util/AySchema.cs
+++ b/server/AyaNova/util/AySchema.cs
@@ -690,7 +690,7 @@ $BODY$;
await ExecQueryAsync("CREATE TABLE anotifyevent (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, created timestamp not null, " +
"ayatype integer, objectid bigint, eventtype integer not null, subscriptionid bigint not null, idvalue bigint, decvalue decimal(19,4), eventdate timestamp, message text)");
- await ExecQueryAsync("CREATE TABLE anotification (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, created timestamp not null, ayatype integer, objectid bigint, eventtype integer not null, " +
+ await ExecQueryAsync("CREATE TABLE anotification (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, userid bigint not null, created timestamp not null, ayatype integer, objectid bigint, eventtype integer not null, " +
"subscriptionid bigint not null, message text, fetched bool not null)");
await ExecQueryAsync("CREATE TABLE anotifydeliverylog (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, processed timestamp not null, ayatype integer, objectid bigint, " +